Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!


Forgot your password?
PHP Programming IT Technology

An Early Look At What's Coming In PHP V6 307

IndioMan writes "In this article, learn about the new PHP V6 features in detail. Learn how it is easier to use, more secure, and more suitable for internationalization. New PHP V6 features include improved support for Unicode, clean-up of several functions, improved extensions, engine additions, changes to OO functions, and PHP additions." Update — May 7th at 16:47 GMT by SS: IBM seems to have removed the article linked in the summary. Here's a different yet related article about the future of PHP, but it's a year old.
This discussion has been archived. No new comments can be posted.

An Early Look At What's Coming In PHP V6

Comments Filter:
  • Finally (Score:2, Insightful)

    by Anonymous Coward

    It's about time PHP has native support for unicode.

    • Re:Finally (Score:4, Interesting)

      by sopssa ( 1498795 ) <sopssa@email.com> on Wednesday May 06, 2009 @03:13PM (#27849823) Journal

      One thing I hope PHP would have is GUI stuff for both Windows and Linux. Its a great language for everything, and I use it constantly for scripts and other stuff. I've even written ircbots and servers with it, and they all work great and are nice to work with.

      However the GUI design with the existing tools is just pain in the ass, and it doesnt offer a good way to turn your code into machine code.

      I do understand that theres programming languages like c/c++ and delphi and several others, but from all of those php is the nicest to use, even for non-webpages stuff.

      I dont think it would be that hard to implement such, given theres people to do it and understand how PHP can be greatly used for non-webserver stuff aswell. Or is there something against it that I havent thought of?

      • Re: (Score:2, Insightful)

        by ShawnCplus ( 1083617 )
        There is the PHP GTK project but I'm a PHP developer and even I'm wondering why you would choose PHP for developing a GUI desktop app.
        • Re:Finally (Score:5, Interesting)

          by dgatwood ( 11270 ) on Wednesday May 06, 2009 @04:27PM (#27850745) Homepage Journal

          Because it's syntactically similar to C. It's remarkably close to what C++ should have been---C with classes, integrated hashes, variable-length arrays, and usable string manipulation. Thus, for long-time C programmers, it's a very natural language to pick.

          • Re: (Score:3, Interesting)

            by ShawnCplus ( 1083617 )
            I've programmed in both C and C++ and I've used PHP GTK and I'd choose X86 Assembler to build a GUI before I choose PHP for desktop GUI development. And all of the benefits you mentioned are almost completely alleviated with Boost
          • Re: (Score:3, Informative)

            by zoips ( 576749 )
            You should check out Pike [ida.liu.se]. Lot nicer than PHP and still has all of those things you mentioned.
      • by joss ( 1346 )

        Funny, very very dry, but damn funny.

      • Re: (Score:3, Interesting)

        by ooloogi ( 313154 )

        I didn't mind PHP until I tried porting a a PHP text processing application I'd written into C++. The conversion into C++ (with STL and Boost) was essentially line-for-line, so the lines of code was the same, but the C++ was more readable. The PHP runtime was 32ms, while the C++ was 1.9ms.

        Even in PHP territory, PHP wasn't giving any advantages, but several disadvantages.

    • $output = fopen('outputfile.txt', 'wt');
      fwrite($fp, $uni); // writes out data in UTF-8 encoding

      ..... not where you expect it it dossent....

    • Re:Finally (Score:5, Funny)

      by clone53421 ( 1310749 ) on Wednesday May 06, 2009 @04:14PM (#27850583) Journal

      Too bad Slashdot still wonâ(TM)t.

      I mean, won't.

  • So... (Score:5, Informative)

    by msh104 ( 620136 ) on Wednesday May 06, 2009 @02:32PM (#27849259)

    without wanting to be overly sarcastic..

    What features are they gonne break this time?

    • Re:So... (Score:5, Insightful)

      by 77Punker ( 673758 ) <spencr04@DEGAShi ... du minus painter> on Wednesday May 06, 2009 @02:44PM (#27849427)

      Gotta break some eggs to make an omelet.

      Hopefully this will include cleaning up the argument lists of the string and array functions so that they hall take f($needle, $haystack) in a consistent order. Fixing the argument lists isn't in TFA, but it's a really obvious place to start.

      At work, it may give me an excuse to rewrite a horrible old app that's been holding us back since the days of PHP4. I suspect I am not alone in wanting to see some old (buggy, slow, insecure, poorly designed) PHP apps get ruined so that they can be redeveloped now that PHP5 is actually a decent language.

      • The function naming convention needs to be fixed as well as the argument lists that you mention. The naming scheme is a little haphazard. Although if you use eclipse or another dev suite, autocompletion of the function names etc does save having to constantly look it up.
      • mod +1; I also hate the Needle/Haystack Haystack/Needle operator ordering..
        of course upgrading your code to make it compliant will be a PITA...

      • Re:So... (Score:5, Informative)

        by msh104 ( 620136 ) on Wednesday May 06, 2009 @03:01PM (#27849699)

        At my work we host and have build and maintain a little over 200 php websites. We host them all ourselves. ( the CMS that we use is build in PHP )

        We earn money from both the hosting and the developing.

        Many of our customers don't want to pay for the porting of their websites to PHP5, let alone PHP6. usually this requires upgrading the CMS as well, making modifications to custom extentions written by outsourcing partys, etc. All in all quite expensive for the site owner.

        "Threatening" them with PHP4 server shutdowns only makes them go away to other hosting providers that will over PHP4 to them.

        So we ended up virtualising all the PHP4 sites together with a good backup system and making our customers understand that we provide no warrenty anymore. We will help them when things blow up on an paid per hour basis.

        Another problem is that we cannot reuse a lot of our code anymore now. Many of our new plugins require php5 so we have to modify them to make them php4 compatible again.

        when php6 comes out we will have to support three different php versions... the horrors of that vision already scare me today..

        • Staying up to date is part of doing business. Would you use a cab that still used horses? Get on a steam train with open box carts?

          While progress for progress sake can be overrated the simple fact is that we learn from mistakes and improve on the stuff we make. There comes a time when being conservative turns you into a technical ludite and as a tech company you got to ask yourself, is this worth it?

          Is there a business in supplying coal for instance? Some people still heat their houses with it, but does t

          • by Phroggy ( 441 )

            Is there a business in supplying coal for instance? Some people still heat their houses with it, but does that mean YOU as a business man have to run a business to supply them?

            No, but it does mean if YOU choose not to supply them with coal, somebody else will.

            The parent isn't complaining because he doesn't want to stay up to date. He's complaining that they have a lot of customers who don't want to stay up to date, and there's nothing he can do about that except stop taking their money.

            Ask yourself, how much time does it cost you to keep the people happy who want PHP4 and how much that same time could have earned you in business from PHP5 customers.

            Unfortunately, turning away PHP4 customers doesn't mean more PHP5 customers will suddenly sign up. They are currently supporting both, and while of course there is a cost associated with continue

        • Re: (Score:3, Interesting)

          by ukyoCE ( 106879 )

          There are some new features in php 5 and php 6, but besides some worst offenders (magic quotes and registered globals) are entirely backwards compatible with PHP 4 code.

          I had the pleasure of upgrading a Large website from PHP 4 to PHP 5 and it was honestly quite trivial. 5 to 6 will be the same, except for removing the option of turning magic quotes and registered globals back on. But you fixed it the right way from 4 to 5 by not using them anymore anyway, riiiight? :)

      • by Firehed ( 942385 )

        It won't happen to the base functions simply for backwards-compatibility, but given that namespace support is being added into PHP6 (I think it's also in 5.3; I have 5.2.6 on my machine so I don't know for sure) they could re-map all of those old functions in the global namespace into new logically-named and consistent functions. Array and string manipulation functions come to mind as the worst offenders, but there's plenty of other bad stuff as well. I think a lot of it would do well to be remade into bui

    • Re: (Score:3, Informative)

      by ukyoCE ( 106879 )

      You must be confused, are you thinking of Perl?

      PHP has been VERY careful about breaking features, and have essentially openly mocked the people who suggest they "fix" PHP's functions by randomly swapping argument order on functions that have been working just fine for years.

      The only thing I can think of they've broken is MAGIC_QUOTES and registered globals. Both are Very Bad Things that it was important they do away with. Any sane PHP code will react to their removal by simply removing a few chunks of goo

  • by thue ( 121682 ) on Wednesday May 06, 2009 @02:41PM (#27849389) Homepage

    All very good. But there is no set release date; I wonder when PHP 6 will be released?

    They have been working on PHP 6 since at least 2005, and from monitoring announcement etc., I haven't seen any signs that they are nearing a release.

    • Re: (Score:3, Funny)

      by Burkin ( 1534829 )
      I heard it'll be released the same day as Duke Nukem Forever as 3D Realms will be using it in the relaunch of their site for the game.
    • Re: (Score:3, Informative)

      by AndrewNeo ( 979708 )
      I don't care, as long as they fix all these inconsistencies and everything everyone else complains about, then they can take their time.
  • by Onyma ( 1018104 ) on Wednesday May 06, 2009 @02:43PM (#27849419)
    I am definitely no PHP expert so perhaps I am wrong but it seems that much of what is being changed is backtracking due to bad language decisions from the beginning. Sadly I think PHP developers with legacy code are going to be paying the price for several versions to come.
    • by FictionPimp ( 712802 ) on Wednesday May 06, 2009 @02:45PM (#27849451) Homepage

      This is why I never write legacy code, only progressive forward thinking code!

      People who write legacy code are just not thinking of the future.

      • You will love it when they add functional approach and constructs. Declarative style in php for more points!

    • by Anonymous Coward on Wednesday May 06, 2009 @02:50PM (#27849541)

      You're not far off track. A lot of PHP's problems stems from the fact that the language itself was more or less kind of thrown together rather than planned out (from the early simple Personal Home Page scripting stuff to PHP3 that just kept extending things and adding more functionality bolted on). They only just began to start to stabalize some of that in PHP4 and really only started to fix a lot of issues in PHP5 and now PHP6. They are making good strides but there's a lot of work to do (and a lot of backwards compatible considerations, I'm sure).

      The good news for PHP developers with legacy code is that they've had a long time to fix things. Stuff that is going away has been deprecated for many versions now so none of this should be a surprise. The people that will get hit are the site administrators using PHP based apps that haven't been updated in forever.

    • by 77Punker ( 673758 ) <spencr04@DEGAShi ... du minus painter> on Wednesday May 06, 2009 @02:53PM (#27849577)

      I think PHP developers with legacy code are going to be paying the price for several versions to come.

      I prefer to call it "job security".

  • question: (Score:5, Insightful)

    by larry bagina ( 561269 ) on Wednesday May 06, 2009 @02:50PM (#27849543) Journal
    are these ass clowns still planning on using \ for namespaces?
  • A likely story (Score:5, Insightful)

    by Anonymous Coward on Wednesday May 06, 2009 @02:51PM (#27849547)
    As far as I can tell, PHP 6 is probably a long way off. End of 2009 at the very earliest. Consider this: PHP 5.3 introduced RC1 in March with the idea of 1-2 week intervals, and, here in May, we're still not at RC2.

    Given that PHP 6 was "rumored" to be out at least a year ago. I can't decide if the title "An Early Look" is meant to be ironic, or is just a sad indicator of progress.

    Despite that, I would say that three things have recently happened demonstrating the improvement in quality of PHP:
    1. End of Life of PHP 4
    2. Many important improvments in PHP 5.3
    3. Unicode in PHP 6

    I would say that (1) and (2) easily are more important for the language than is (3). PHP 5.3's improvements should be a huge change: Namespaces (I know there's a huge amount of hate for this implementation: get over it. It's going to be very useful), Closures / Lambda Functions, and Late Static Bindings in particular make it hard to wait so long for PHP 5.3.

    So, stop talking about PHP 6! Lets get PHP 5.3 out.

  • I hope it handles search/replace better. I tried doing a search/replace on a 88MB large string and the stupid script crashed! ;-)

    Seriously, though, if anyone knows of any good tactics for large-string searching/replacing, I'd be happy to hear them. My current attempt is multiple page loads in an iFrame while the user is presented with a "working on it..." message.

    • by drpimp ( 900837 ) on Wednesday May 06, 2009 @03:00PM (#27849671) Journal
      Like any other computer science problem, break it into pieces (think Divide and Conquer). Loading 88MB file into memory is not going to work by default anyhow, unless you set the memory limit in PHP from the default you will get out of memory errors every time. I think even a find/replace in a Windows app like Notepad or Notepad++ will "work" but it will definitely be slow. When I used to search large logs I would use some sort of file splitter and search each file itself.
      • Loading 88MB file into memory is not going to work by default anyhow, unless you set the memory limit in PHP from the default you will get out of memory errors every time. I think even a find/replace in a Windows app like Notepad or Notepad++ will "work" but it will definitely be slow. When I used to search large logs I would use some sort of file splitter and search each file itself.

        And here the rest of us are grepping and sedding multi-gigabyte files without thinking twice. Seriously, what's your idea of a large file?

      • Re: (Score:3, Informative)

        by nahdude812 ( 88157 ) *

        If you want to process large files (or any large chunks of data such as blob columns) in PHP without loading the entire file into memory, look into streams.

    • Have PHP run a command-line SED or AWK script. Without more details of how your 88mb file is structured, I can't predict how effective this suggestion is.

    • by Bigby ( 659157 )

      Assuming this 88MB string is in a file, you should never load the whole file. Open the file and read it chunk by chunk. As you read it chunk by chunk, do a search/replace on each chunk and write the replaced chunk to another file. You need to remember to catch the matches that span more than once chunk though.

      The question should really be why you are dealing with an 88MB file in PHP...

      • by Firehed ( 942385 )

        Well, I once had to use PHP to re-import a MSSQL DB that was something like 25GB because no SQL machine was able to import even one of the 133 (?) files that made up the DB contents. Had to leave it running for something like 17 hours, but I think it ended up getting the job done well enough for what needed to be done.

        But yeah, I tend to avoid dealing with any large files in PHP whenever possible.

  • Limited cleanup (Score:5, Insightful)

    by Just Some Guy ( 3352 ) <kirk+slashdot@strauser.com> on Wednesday May 06, 2009 @02:59PM (#27849665) Homepage Journal

    clean-up of several functions

    Does that include safe_quote_string_this_time_i_really_freaking_mean_it, or do_foo(needle, haystack) and foo_do(haystack, needle)? At least it gets namespaces after all this time, even if they're almost deliberately ugly.

  • by Parker Lewis ( 999165 ) on Wednesday May 06, 2009 @03:00PM (#27849679)
    My items to fix: - Remove the "goto" statement that will be introduced in 5.3 (WHY JESUS, WHY??); - Stardandize function names (current samples: str_replace, html_ entity_ decode, htmlentities, htmlspecialchars_decode); - Improve array speed (for simple arrays, use internally one simple C array/list - current days, any array is a map); - Insert optional configurations by project (and not by host); - Remove function alias; - Provide optional typing for functions and parameters, but in a simple and consistent way (no strange notations); - Remove old extensions, like PDF paid extensions (and please, insert any open and official PDF extension); - As any language, provide a way of store compiled regex, avoiding compile them all the simple regex call for the same task; - Provide legacy support for PHP5 application as separated download (or at least allow PHP6 and 5 in the same host - we suffer a lot to find PHP5 Hosting in the earlier times, due the impossibility of run PHP4 and 5 at the same host).
    • Re: (Score:3, Informative)

      by nahdude812 ( 88157 ) *

      PHP compiles regex's transparently automatically. If you've used a pattern recently, it will not reparse the statement.

    • Re: (Score:2, Informative)

      by bluej100 ( 1039080 )

      Improve array speed (for simple arrays, use internally one simple C array/list - current days, any array is a map);

      Try the SplFixedArray class [php.net]. The SPL data structures are much, much faster. [blueparabola.com] I actually rather like the "easy by default, fast when you need it" dichotomy.

  • Namespaces (Score:5, Interesting)

    by Phroggy ( 441 ) <slashdot3@[ ]oggy.com ['phr' in gap]> on Wednesday May 06, 2009 @03:02PM (#27849713) Homepage

    So let's say you've got a global variable, $n

    And let's say you're using it in a module, Foo

    And because scattering global variables everywhere is a stupid idea that will lead to much pain, let's say you've decided to use namespaces in PHP6.

    Now, in your main script, let's say you happen to be using a variable $Foo, for no particular reason.

    What does this do?

    echo "Hello $Foo\n";

    • Re: (Score:3, Funny)

      by ari_j ( 90255 )
      It'll probably just print 90 copies of an error message that makes sense on the surface but gives no indication of what it actually means.
    • Use {$Foo} instead. It's the proper way to put variables in a string.

    • Re: (Score:3, Insightful)

      by edsousa ( 1201831 )
      Say that $Foo=3
      It will print
      Hello 3

      Because the namespace begins with a backslash ('\foo\n') and when using it inside double quoted strings must be "\\foo\\n".
      • by Phroggy ( 441 )

        Say that $Foo=3
        It will print
        Hello 3

        Because the namespace begins with a backslash ('\foo\n') and when using it inside double quoted strings must be "\\foo\\n".

        The example in the article didn't mention leading with a backslash, or at least I don't think it did (it's been slashdotted, apparently).

        And seriously? You have to escape the backslashes? What if you want a literal backslash now?

    • Hey, I can't imagine that would be asked a lot or anything. There's no way that would be in the PHP FAQ [php.net]!

      Oh wait...

    • by Firehed ( 942385 )

      It'll print $Foo followed by a newline.

      Foo\$n would print $n in the Foo namespace. I think. Strictly speaking, you should wrap it in curly braces if you're using anything other than a "non-complex" (for lack of a better term) variable, including array contents and object members.

      If variable $Foo was a string that contained the name of some namespace ("bar", for example), then if it wasn't in a quoted string context it would look for constant bar\n, but constants aren't echoed when quoted.

      That said, I still

  • by omuls are tasty ( 1321759 ) on Wednesday May 06, 2009 @03:46PM (#27850245)

    In the finest tradition of PHP, they made Unicode behaviour dependent on a setting. Have these people learnt nothing from the past? magic_quotes anyone? Bleh. All languages have their warts, but the amount of bad design decisions in this one is just staggering.

  • New to this version (Score:3, Informative)

    by KingPin27 ( 1290730 ) on Wednesday May 06, 2009 @04:18PM (#27850651)
    they have actually turned off the register_globals feature (really this time it won't work). If you try to use it you get an error message that says RTFM (ERROR: ID-10-T)
  • by greywire ( 78262 ) on Wednesday May 06, 2009 @05:33PM (#27851845) Homepage

    PHP: its like fast food..

    You know its bad for you...

    You feel like crap after eating it...

    But damnit, its right there, oh so conveniently located on the way to work, and sometimes a greasy cheeseburger just hits the spot, even though you know you'll pay for it later in heartburn and much later in high cholesterol and love handles, even though right now its really cheap on the wallet.

    Its a guilty pleasure.

    And while you're sucking down that greaseball burger, you see the local soup and salad restaraunt and think "next time, I'll eat right.."

    But come the next day and you see that taco joint and..

  • by Udigs ( 1072138 ) on Wednesday May 06, 2009 @07:26PM (#27853107)

No problem is so large it can't be fit in somewhere.