Forgot your password?
typodupeerror
PHP Programming IT Technology

PHP 5.3 Released 120

Posted by timothy
from the phffp-phffp-phffp dept.
Sudheer writes "The PHP development team is proud to announce the immediate release of PHP 5.3.0. This release is a major improvement in the 5.X series, which includes a large number of new features and bug fixes. Some of the key new features include: namespaces, late static binding, closures, optional garbage collection for cyclic references, new extensions (like ext/phar, ext/intl and ext/fileinfo), over 140 bug fixes and much more."
This discussion has been archived. No new comments can be posted.

PHP 5.3 Released

Comments Filter:
  • Now I don't have to do a song and dance of ugly hacks to get what I need from a file on systems without the extention.

    Oh wait, almost any PHP project eventually gets reduced to a song and dance of ugly hacks.

    • Re: (Score:2, Funny)

      by Anonymous Coward

      Oh wait, almost any PHP project eventually gets reduced to a song and dance of ugly hacks.

      *sigh* Yes, yes, we know, and Python or insert-your-pet-language-here is a gloriously clean and not-at-all counterintuitive* wonderland of fantasy and enchantment where fairies and elves smile upon you and give you their blessings and unicorns piss rainbows and shit candy.

      At least until the next hip, trendy language comes out. How's your Ruby on Rails coding coming along?

      *: Obviously, because if anyone finds it counterintuitive and an ugly hack, they are wrong and ugly and stupid and smell funny so there.

      • Re: (Score:2, Troll)

        I use php and do enjoy it but it is ugly. There is no consistency within the function naming, using -> over . Or any other single symbol is dumb and __construct() but why two underscores? It's unnessary.
        • by i_ate_god (899684) on Tuesday June 30, 2009 @11:36AM (#28530231) Homepage

          __construct() is a magic method, just like __get(), __set(), __destruct(), __isset(), __toString(), so on and so forth. Magic methods are called without the programmer having to call them, under specific circumstances. In the case of __construct(), it's called when an object is instantiated. '__' defines a magic method and was chosen back in the day because PHP didn't have protected/private members and so the common practice was to prefix private/protected members with one underscore.

          PHP was a solution to Perl, so -> is what Perl uses so that's what PHP uses.

          The function naming is not so much an issue either. But what is frustrating is argument order. That's something that really needs to be revamped, backwards compatibility be damned.

          • Re: (Score:2, Informative)

            by searlea (95882)

            Assuming your argument-order frustration lies with the classic needle/haystack inconsistency throughout the string and array functions, the whole issue goes away if the PHP guys would simply evolve the string and array natives to be treated like objects:


            in_array($needle, $haystack) -> $array->contains($needle)
            strpos($haystack, $needle) -> $string->pos($needle)
            etc.

            Do that, and people will naturally migrate from the old inconsistent methods and move towards the more natural and consistent new meth

      • Re: (Score:3, Insightful)

        It's funny how people cling to languages for arbitrary and sometimes downright illogical reasons. It's like each language is cool or acceptable in various online social circles. In fact, they can be broken down into their equivalent high school archetype:
        • PHP - The Slackers
        • .NET - The Jocks
        • C - The Goths/Hardcore
        • Ruby - The Hipsters
        • Haskell - The Nerds
        • Java - The drifters

        In seriousness, I'm with the OP. I wish the ridiculous language evangelism would stop. In the end, people are just being short si

        • Re: (Score:3, Interesting)

          by K. S. Kyosuke (729550)
          What am I, as a Schemer? A minimalist? A chess player [mit.edu]? But seriously, I always saw PHP as one of the prime examples of cargo cult language design. "Perl has strings in front of variables, let's copy them, gods will be pleased." Obviously no one cared that in Perl, the sigil has some actual meaning, like in shell, unlike in PHP, where the single type of variables could be handled the same way it is handled in Python, Ruby, stc. And then the adoption of that strange Java-like OOP system, quite weird for a dyn
          • by jbezorg (1263978)

            Version 1 & 2 of PHP was a Perl library and was originally named "Personal Home Page Form Processor". That's the original source of the sigil in front of the vars ( and the name "PHP" and a lot of other holdovers ). Version 3 was converted to C.

        • Re: (Score:3, Interesting)

          by Majik Sheff (930627)

          Thank you, you got the gist of my post.

          Every language has its strengths, weaknesses, glaringly awful bits, shiningly wonderful bits, and all of the subculture that go with those things. No language is perfect or even acceptable for every job.

          PHP is an extremely organic language. It is the result of hundreds of developers' efforts and the inclusion of many modules that were once addons.

          I've been using it since very early version 3.0, so I know why things are named the way they are. That doesn't make them

          • by ari_j (90255)
            It's sad that Slashdot doesn't have an "accomplishment" for the +5 Flamebait. Everyone should strive for one. Oh, and you should get bonus points if it is not a politics or religion article.
            • Re: (Score:3, Funny)

              by andi75 (84413)

              slash-achievements!

              Achievement unlocked: [ Post 5 consecutive posts using the Preview button first ]

      • by dkleinsc (563838)

        Having used PHP along with a whole slew of other languages, what I've generally found is that like most other languages PHP is a bit of a slave to its own history.

        For PHP, its origins in dynamic web pages lead it towards results which are quick and often convenient for web designers who are great at making sites pretty, but lacking in design consistency and rigor. Some effects of this are APIs with inconsistent naming and structure compared to other languages, and the prevalence of bad code practices among

        • by ultrabot (200914)

          For Python, it's emphasis on simple syntax means that it's very hard to determine the capabilities of an object just by looking at the code that uses it. Choose bad variable names and you'll be in real trouble.

          What the hell does this mean?

          • by dkleinsc (563838)

            Here's an example:

            def foo(bar):
                    myVar = bar.baz()

            Quick, what methods are available to be called on myVar? Answer: you have no idea, unless you know what bar is, and what bar.baz() returns.

            Don't get me wrong, I like a lot about Python (and actually it's currently my primary language on the job), but it does have some downsides.

    • Re: (Score:2, Offtopic)

      by nedwidek (98930)

      PHP as I told a manager is useful because it is ubiquitous, not because it is perfect or even particularly good. At the time I worked on a derivative of GForge, which is a definite example of the horrors that can come from PHP projects.

      This is also an original quote by me: "The beauty of PHP is that it is so simple even an idiot can program with it. The problem with PHP is that so many idiots do choose to program in it."

      In my own hosting, I have the choice of using RoR, but the app must be manually redeploy

      • by sopssa (1498795)

        5.3 should be cool, now I just need to start pestering my hosting providers about upgrading.

        Dude, dedicated server!

        I also always pick PHP because its so nice to code with it and because of the box it provides so many different functions from many areas. It saves you lots of time and work if you dont need to always write your own functions for everything or google for a library. This is also why I prefer Delphi over C++.

    • Pfffft!

      Everything changed with the release of Drupal (written in PHP).
      We are creating several large projects each year based on Drupal/PHP and our solutions easily bests any proprietary solutions I've encountered so far.

  • You forgot the most important change of all.

    They added support for "goto".

    • Yes, adding goto in a language automatically adds multiple levels of awesome.

      It doesn't make the code less debug-able at all.

  • features! (Score:2, Informative)

    by Lord Ender (156273)

    PHP now comes with more GOTO!

  • by TheNinjaroach (878876) on Tuesday June 30, 2009 @10:03AM (#28528597)
    Say what you will about PHP, but it puts food on my table and a good roof over my head. I have been clamoring for the new features in PHP 5.3.0 (closures, namespaces, they finally killed register_globals) and can't wait for the improvements coming in 6.

    I truly appreciate the hard work of the PHP development team and the free language they have given us, congratulations on the new release.
    • by nedwidek (98930)

      Hallelujah on the register_globals. At least magic quotes are now deprecated. Here's looking forward to 6.0 when they are finally removed!! (I've talked to way too many devs who think they are adequate protection against SQL injections)

  • Horray (Score:5, Funny)

    by neoform (551705) <djneoform@gmail.com> on Tuesday June 30, 2009 @10:05AM (#28528643) Homepage
    So does this mean I should upgrade from PHP 3.2? Are there any incompatibilities with my existing code?

    Maybe someone can look over my login script and tell me if this will work in PHP5?

    $query_login="select * FROM user";
    $result_login = mysql_query($query_login) or die("Your passwrod is might be bad I think");
    //$login_check = mysql_num_rows($result_login);
    while($row=mysql_fetch_array($result_login))
    {
    $username=$row["username"];
    if ($username==$username1)
    {
    echo "";
    echo "window.location.href='login_error.php?rec=qq';";
    echo "";
    exit;
    }
    }
    • Re: (Score:1, Insightful)

      by Anonymous Coward
      That's the shittiest login code I've ever seen, and friend, that's saying something.
    • by chord.wav (599850)

      STAY AWAY FROM THE KEYBOARD RIGHT NOW!! That's it, easy, let go... That's all gonna be alright... (Pst! Somebody call 911..)

    • Re:Horray (Score:5, Funny)

      by Anonymous Coward on Tuesday June 30, 2009 @12:00PM (#28530859)

      If you can't tell that the parent post is a joke you're probably a PHP programmer.

      • by jbezorg (1263978)

        LOL... I'm a PHP programmer.

        *sigh* Someone a few posts up basically said this: "A language so simple an idiot can us it... so a lot of idiots do.". Sadly, I have to agree. A majority don't know what SQL injection or HTTP Response Splitting is.

        • ....but some of us do!

          Not all PHP coders are idiots. I code in many different languages that are required of me while I'm at work. But for some reason I just love how easy it is to put something together in PHP when I'm home playing with some hobby code..
          • by jbezorg (1263978)
            I've been doing code reviews for PHP novices and sub-contractors lately and it's had it's /facepalm moments. I did have the pleasure of introducing them to little bobby tables though.
  • by bogaboga (793279) on Tuesday June 30, 2009 @10:08AM (#28528701)

    ...is the ability to employ goto, though it is not allowed to jump into a loop or switch statement. A fatal error is issued in such cases.

    • Re: (Score:3, Funny)

      by Canazza (1428553)

      so it's goto, but not as we know it?

    • How could you jump into the middle of a loop or a switch statement? It doesn't make sense. Essential context is missing. They ruled that out for a good reason; it's like teleporting into a blender.
  • The lack of namespaces in any programming language is a massive car wreck just waiting to happen. I once spent a few days trying to resolve an issue with a web portal application with different components brought together where the issue was caused entirely by a function name collision.

  • see whats new in PHP 5.3 [webdigi.co.uk]. Namespaces, phar, Closures & Lambdas, Functors, Traits,Magic functions. See link above for examples.
    • by amicusNYCL (1538833) on Tuesday June 30, 2009 @10:57AM (#28529485)

      You can also read the official release announcement instead of some random guy's blog.

      http://php.net/releases/5_3_0.php [php.net]

      • by ari_j (90255)
        This is slashdot. We only link to blogs. Preferably blogs that only link to other blogs. Sometimes we link to digg or fark.
    • by caseih (160668)

      The backslash name separator looks awful to me, although I've always found PHP code kind of garish with all the dollar signs and curly braces. Although it's at least readable compared to some perl I've seen!

      Looking at the "what's new" list I see the cool new feature of php archives. .phar files are zips or tarballs that can be included all at once in your program. Seeing that brings up something I've always struggled with in PHP. When should one use "include," "include_once," "require," or "require_once?

      • by i_ate_god (899684)

        The backslash name separator looks awful to me, although I've always found PHP code kind of garish with all the dollar signs and curly braces. Although it's at least readable compared to some perl I've seen!

        Looking at the "what's new" list I see the cool new feature of php archives. .phar files are zips or tarballs that can be included all at once in your program. Seeing that brings up something I've always struggled with in PHP. When should one use "include," "include_once," "require," or "require_once?" Seems like include normally just inserts the included file into the current source code as if it was there to begin with, no? I guess in the past without namespaces that's probably what most people needed most of the time. And after converting my development wholesale to python with it's inherent namespaces (which are really just singleton objects bound to a local name), it seems like PHP's system is a bit convoluted.

        In a nicely made OOP application, you should never have to explicitly use require/include and instead use a class autoloader.

    • by greywire (78262)

      Unfortunately traits did not make it into 5.3.

      Which sucks because I thought that was one the coolest new things.

  • Let's say you've been using PHP since about a month after Rasmus released it 15 years back, so you've got a whole lot of code that uses the ereg family of regex functions. So they've depricated them, and plan to yank them from PHP 6. Why? Is the overhead so terrible? Or do they really think that it will improve our lives if we have to go back through everything and translate eregs to pregs?

    Then there's the change in MySQL password formats. Sure, if they include the latest MySQL libraries they have a differe

    • There's a huge codebase out there that's using PHP against MySQL, and using PHP's original ereg regex syntax instead of the Perl-wannabe stuff. What are they thinking, when they set out to break this? When 5.3 rolls out through the distros a whole lot of MySQL backends will fail on the password thing. And when 6.0 rolls out millions of regexs will suddenly be failing. Needlessly.

      Given the current state of the economy, this is how you can help keep PHP programmers employed... and why you have a test environment where you install new stuff like this before deploying it across your platforms... so you can find all of the pitfalls, traps, changes, etc, without causing your site to fall down and go boom.

    • They've been talking about these changes for a long, long time. If you're still using ereg, or register globals, or magic quotes, or whatever else you want to complain about them changing, then that's your problem. If you have important code laying around that you haven't looked through yet, you might want to pencil that in. There's no reason to have PHP4-only code sitting around these days.

    • by tibman (623933)

      Change is almost always painful and scary but you'll be happy for it in the end. Update the code and be glad they don't stay backwards compatable to every iteration of the language.

      It's better to clean up and remove the old stuff and continue improving the language. They don't have enough resources to bugfix and improve such a lengthy/aging codebase.

    • Re: (Score:3, Insightful)

      by DragonWriter (970822)

      There's a huge codebase out there that's using PHP against MySQL, and using PHP's original ereg regex syntax instead of the Perl-wannabe stuff. What are they thinking, when they set out to break this? When 5.3 rolls out through the distros a whole lot of MySQL backends will fail on the password thing. And when 6.0 rolls out millions of regexs will suddenly be failing.

      Uh, no.

      Assuming that people running and maintaining the code are paying any attention, when 6.0 rolls out, those installations that have work

    • Re:Nuisances (Score:4, Informative)

      by Stan Vassilev (939229) on Tuesday June 30, 2009 @11:46AM (#28530483)

      There's a huge codebase out there that's using PHP against MySQL, and using PHP's original ereg regex syntax instead of the Perl-wannabe stuff. What are they thinking, when they set out to break this?

      Nothing is broken. Ereg is moved to the 'official' extension pack called PECL, which you can use for full backwards compatibility. At the same time the community has been warning not to use the ereg functions for the past at least 3-4 years, if not more, citing worse performance, worse featureset, and the possibility of PCRE replacing it at some point in the future.

      • by atamido (1020905)

        Is there somewhere that lists all of the functions that are about to be deprecated? I've used ereg several times in the past few months and am going to have to go and replace those now. It would be nice to avoid the extra work in the future.

    • by profplump (309017)
      They really think having regex functions that aren't binary safe is a bad idea -- besides the obviously disastrous results when used for input validation it also means that ereg cannot support unicode. Plus it's just extra code that there's little reason to continue patching and porting a decade after it has been superseded by faster, safer functions.
  • What feeture is PHP missing already, otherwise I would use it :)
  • OH-MY-GOD! Nobody complaining about the weird namespace separator!
  • by Sicnarf (529730)
    as of this version, windows nt 4 will no longer be supported :-(
    • NT4 is 12 years old at this point. Is this really a surprise?

      I mean, its successor (Windows 2000), is already 9 years old!

  • The PHP development team has no vision, and they haven't ever had one. It's a hodgepodge that started out to be a "web perl" way back in the day, but then Java developers started using it and so 5 looked more and more Java-esque, but obviously being Java isn't their vision either. Take the namespacing in this release. They are using the BACKSPACE as the namespace separator. It's f'ing awful and inconsistent, but they wanted to jam it into 5.3 ... even though Dimitri had a patch that would have used "::" fo
  • Some time ago I *had* to work with PHP. I haven't known it before that. Now I hate it =). At that time I wrote a comparison, out of anger about PHP being so much used. This is the comparison Java - PHP I have wrote [reloco.com.ar].

    • Re: (Score:2, Insightful)

      by tarius8105 (683929)
      Your comparison is off. Working at a company that has over 1000 java applications, I can tell you right now that you're so off. Simple fact, on a slower machine php will outshine java in terms of performance. On a enterprise powerhouse, the performance is about the same give or take based on how both are written. Its also not a fair comparison to compare java servlets to php. PHP to JSP is a fair comparison and your comparison would still be off base especially with the execution model. You cant compare
      • by Nicopa (87617)

        In my experience, in a modern server PHP uses more CPU than Java. You might be right about slow machines though. I don't understand why you make such a big deal about servlets vs jsp, as jsp is just a technology to ease the construction of servlets (every jsp gets converted into a servlet)... And I don't agree you can't compare PHP to Java, they try to serve the same purpose.

        • In my experience, in a modern server PHP uses more CPU than Java. You might be right about slow machines though. I don't understand why you make such a big deal about servlets vs jsp, as jsp is just a technology to ease the construction of servlets (every jsp gets converted into a servlet)... And I don't agree you can't compare PHP to Java, they try to serve the same purpose.

          They serve same purpose, but they both werent invented for the same purpose. Out of the two PHP was designed from the ground up to just serve dynamic webpages, and that is its primary purpose. Java on the other hand is designed as an all purpose language.

  • Can anyone give an example of a good use of lambdas in php? I'd appreciate both 1. A situation where you would *have* to use it ( or the way to do it without lambdas is such an ugly, counter-intuitive hack that no one would do it ), and 2. an example of where you might use lambdas naturally.

    I've been trying to figure them out since they were announced for 5.3. I think I understand them, but I don't know whey or where you would want to use them.
    • Re: (Score:1, Informative)

      by Anonymous Coward

      It might be easier to think about them as anonymous functions than as lambdas / closures, though they're both.

      They can fit anywhere that used to take a callback. For example, array_walk() and array_map() can be written in a much more sane way, without having to create an external function and refer to it by name.

  • Blah de blah PHP is shit because [insert random piece of php code that a programmer could use if they were a complete fuckwit] Everyone should use [insert my favorite scripting language] because [insert totally irrelevant feature nobody give a fuck about]
  • .. begins! Maybe in another 2 years we'll get this into CentOS/Redhat.

    And by the looks of it, we might see PHP 6 around the same time we return to the moon.

    (and I choose the space program as a comparison to another endeavor that seems to be progressing at a rediculously slow pace)

Facts are stubborn, but statistics are more pliable.

Working...