Slashdot Mirror


Changes In Store For PHP V6

An anonymous reader sends in an IBM DeveloperWorks article detailing the changes coming in PHP V6 — from namespaces, to Web 2.0 built-ins, to a few features that are being removed.

31 of 368 comments (clear)

  1. Quick summary by Anonymous Coward · · Score: 5, Informative

    ... for those too lazy to RTFA:
    Additions:
    Better Unicode support
    Namespaces! (this is being backported to PHP 5.3)
    SOAP and the XML Writer/Reader modules compiled in and enabled by default (also in PHP 5.3)
    Removals:
    magic_quotes, register_globals, register_long_arrays, safe_mode
    ASP-style short tags ()
    Freetype1/GD1 support
    ereg (use of preg encouraged instead).

  2. Re:Is this really news? by truthsearch · · Score: 4, Insightful

    Especially since most of the "new" features are either already available or will be included in v5.3. There's literally nothing new here except better Unicode support.

  3. Backwards compatibility is very important by unity100 · · Score: 5, Interesting

    i am servicing around 350+ clients in a small fish web host. even at that small web host, there are a phletora of different scripts, programs that clients are using to conduct their everyday business, their estores, their livelihood. some of them are dependent and locked-in to the software they are using like a small business company that extensively uses ms products is locked into microsoft.

    regardless, backwards compatibility is important for those people. for starters, these are the people who have chosen php as the platform to conduct their business on, making php a de facto dominant language for the web instead of being a small time web language that was used on web savvy, webmasters. the financial impact of this is going to be huge for them, to adopt to that many changes php dev group started to introduce in the span of 1 to 2 years. this is too much.

    you gotta slow down. or you are going to alienate the small business community from using php with what you are doing. if you break a small estore owner's store script every 1.5 years for 'upgrading', the second time you do it they will jump the language ship.

    do not start to become an elitist group out of touch with the people, increasingly caring for nifty programming issues rather than what would the users think.

    1. Re:Backwards compatibility is very important by MROD · · Score: 4, Insightful

      Many commercial PHP-based systems are only now just changing over to PHP5 from PHP4. (Yes, I know...)

      That's the way life is, I'm afraid. Most people who are depending upon these sites and software have no control over the vendors and definitely don't have the ability of fixing the code themselves.

      Changing the API so greatly and so often in a non-backwardly compatible fashion does cause genuine problems.. and hosting sites can't afford to support multiple versions. Well, not unless they charge their customers too higher price for hosting their pages.

      --

      Agrajag: "Oh no, not again!"
  4. Re:Is this really news? by bcat24 · · Score: 4, Insightful

    There's literally nothing new here except better Unicode support.
    True, but better Unicode support is a very major feature in and of itself. Let's face it, writing a Unicode-enabled Web application with PHP 5 is like hunting wildebeests with a BB gun. It's possible, but it sure ain't easy.
  5. Magic Quotes was never a security function. by gandhi_2 · · Score: 3, Insightful

    It was to protect you from the O'Malleys and O'Connors. The PHP framers were obviously fans of Mel Brooks' film, Blazing Saddles: "We'll take the niggers and the chinks but we don't want the Irish". Or I'm missing something.

  6. Real change by Anonymous Coward · · Score: 3, Insightful

    Make it like a modern language.

    Change . (string concat) to +

    Change -> (pointer-to-member operator) to .

    Done. Huge productivity increases.

    Thank you.

    1. Re:Real change by jyurkiw · · Score: 3, Informative

      Ever wondered why they picked the '.' for a concatenation operator over the trusty '+'?

      PHP is a loosely-typed language.

      The '+' is also the arithmetic operator.

      Is a line of code reading
      $c = $a + $b
      adding $a and $b? or is it concatenating them?

      What if $a = 513 and $b = 4201?
      Are we talking about a phone number? Or am I trying to come up with $c = 4714?

      There was a very good reason for having '.' as the concatenation operator.

  7. Re:Too Little Too Late by thetoadwarrior · · Score: 4, Insightful

    Um, no it's not. It's only downfall is that it's too easy to do powerful things so idiots make dangerous code.

    That is not the language's fault. Not everyone wants or needs a JBoss server or something equally silly for their website. PHP is still very good. Safe programming in PHP just needs to be preached more to the new users of PHP and some of the self taught people who perhaps learned off the net from someone else with little experience rather than a book since all books I've seen cover the basics on safety.

    The only thing that annoys me is the fact it's function naming methods aren't consistent. It shows that it's had input from various places without any thought into standardizing things.

  8. Re:Magic Quotes Removed by robo_mojo · · Score: 3, Insightful

    So does this mean that if you are using magic quotes and you upgrade to PHP6, suddenly you will become vulnerable to SQL injection attack? Wow, I'd consider that to be a major regression, then.

  9. Re:Major version? by Splab · · Score: 4, Insightful

    "and a bunch of stuff removed"

    The stuff addressed are some of the widest security holes. On top of that the old way of programming PHP and most guides out there encouraged the usage of these bad functions, getting them totally removed is a huge step forward.

  10. Re:Too Little Too Late by FooAtWFU · · Score: 3, Insightful
    That's not its only downfall. Its other downfalls include some miserable organization and bloated core, though much of this may be attributed to lack of namespace support - which is being remedied, but it's a bit late. There's still a lot of package_name_prefix_with_function_name functions, and I don't see them going away soon.

    Beyond that, and the pervasive "make it easy to do the WRONG thing" un-philosophy, I still haven't heard about it getting lexical scope, closures, and anonymous functions. Of course, this only matters if you're a good programmer (as opposed to merely a Decently Adequate one).

    --
    The World Wide Web is dying. Soon, we shall have only the Internet.
  11. what's with the 'phpsucks' tag? by sneakyimp · · Score: 5, Interesting

    I've noticed that every single article here mentioning PHP is immediately tagged 'phpsucks'. I find PHP incredibly expressive and am always surprised by the incredible variety of libraries/modules/plugins to manipulate graphics, flash, pdfs, to support protocols like SOAP, JSON, etc.

    Perhaps we need an article on 'why php sucks' ?

    1. Re:what's with the 'phpsucks' tag? by FooAtWFU · · Score: 3, Interesting
      You mean like this?

      It's not the lack of modules that people complain about. PHP is excessively convenient, if nothing else. :)

      --
      The World Wide Web is dying. Soon, we shall have only the Internet.
  12. Re:Too Little Too Late by KnightMB · · Score: 5, Insightful

    Unfortunately, everyone has already realized that PHP is an insecure, featureless piece of crap. Real web developers have moved onto other platforms, or stuck with Perl. I think I hear this every time someone has been hurt by a buddy who was able to code circles around them in PHP while they struggled in Perl. Real web developers use every tool at their disposal, not just Perl or PHP only. Your statement alone shows the conceit you have about your own skills as compared to everyone else that makes a living doing web development, apparently much more successfully than you.
  13. New PHP features are great and all but.... by FilthCatcher · · Score: 5, Interesting

    My biggest issue with new PHP changes is fact that the sheer size of the PHP libraries mean that these new features don't bubble through to the whole core.

    For exmaple take the newish try / catch exception features. On first glance you think "finally I can write decent exception handling into my own code" - which is great for your own exceptions but too many of the core functions used by your code or by a framework you're using don't throw exceptions - they indicate an error codition in the function's result.

    So now we're seeing loads of code out there by people trying to do things "The right way (tm)" but it's full of bugs as there's exception conditions being raised by core functions that don't get caught by the catch blocks.

    The line from TFA that concerns me is "Much improved for PHP V6 is support for Unicode strings in many of the core functions"

    Many? That will means developers will start using unicode only to find scattered lines of code throughout the app doesn't work as the core function it uses doesn't support unicode. The overhead of keeping track of which functions do and don't support unicode will be a nightmare.

  14. Re:Is this really news? by dgatwood · · Score: 4, Informative

    What makes PHP nice is that, language-wise, it is basically C plus a subset of C++ wrapped up in a scripting language. Almost any code written in C (or C++ without templates/exceptions/other icky stuff) can be trivially ported to PHP by replacing the type names with "var" and adding dollar signs in the right places. (I'm exaggerating slightly, but not much.)

    PHP doesn't have any weird syntax like Perl regular expressions---you can do Perl regex, but it is neatly encapsultated into proper strings the way it should be. There's no having to manually re-indent dozens of lines of code because you needed to add another nesting level and whitespace is part of the language, etc. It's just a really clean, lightweight OO language that's exceptionally easy to learn and happens to integrate very well with HTML.

    Don't get me wrong, PHP has plenty of weak points when it comes to performance (particularly when dealing with massive complex data structures), availability of modules to do various obscure things, etc., but as a language, it is pretty nice, IMHO---mainly because it isn't a kitchen sink like Perl.... :-)

    --

    Check out my sci-fi/humor trilogy at PatriotsBooks.

  15. Re:Is this really news? by moderatorrater · · Score: 4, Insightful

    and happens to integrate very well with HTML Yes, like regular expressions happen to be good at finding string patterns. PHP is good because it is first, foremost, and almost exclusively a web scripting language, which means you get really like features like super globals, HTML embedding, loose typing, great escaping functions, etc. Most other languages try to be all things to all people, but PHP has a focus and it does it pretty well.
  16. Re:Is this really news? by chromatic · · Score: 4, Funny

    PHP doesn't have any weird syntax... It's just a really clean, lightweight OO language.... as a language, it ... isn't a kitchen sink like Perl.

    Did you have to shower after writing this? Did you at least burn the keyboard?

  17. Re:Is this really news? by mini+me · · Score: 3, Insightful

    What makes PHP nice is that, language-wise, it is basically C plus a subset of C++ wrapped up in a scripting language.

    That's the problem with PHP. It requires all the hard work of writing C-like code, without any of the benefits that one might chose C for.
  18. Re:Magic Quotes Removed by Just+Some+Guy · · Score: 5, Funny

    So does this mean that if you are using magic quotes and you upgrade to PHP6, suddenly you will become vulnerable to SQL injection attack?

    Of course not! Since no one has been stupid enough to directly insert submitted strings into SQL before sending it to the server for at least 5 years now, this won't affect any modern code in the slightest.

    --
    Dewey, what part of this looks like authorities should be involved?
  19. Re:Magic Quotes Removed by Quietust · · Score: 3, Informative

    So does this mean that if you are using magic quotes and you upgrade to PHP6, suddenly you will become vulnerable to SQL injection attack?
    It would probably be more accurate to say that you will become more vulnerable to SQL injection attacks, since magic_quotes was never 100% foolproof to begin with.
    --
    * Q
    P.S. If you don't get this note, let me know and I'll write you another.
  20. Re:Is this really news? by SanityInAnarchy · · Score: 3, Interesting

    More pointedly: If poorly-indented code is so troublesome that you'd "hate" the offending developer, you should start using a modern IDE. I prefer a modern editor to a modern IDE.

    I do want a certain amount of control over the structure of my code, even if a lot of it will be by convention. Having any automated tool try to "fix" someone else's code is likely to screw up things like comments which are cleverly indented and aligned with some code, or similarly interesting code.

    And an IDE is overkill in many other ways, yet they still often find ways to miss some functionality I want. That, and I tend to be much more easily able to switch text editors than switch IDEs.

    Disclaimer: I'm not GP, and I use Ruby.
    --
    Don't thank God, thank a doctor!
  21. Re:Is this really news? by chromatic · · Score: 3, Funny

    It's the only way to be sure.

  22. Re:Magic Quotes Removed by TheLink · · Score: 4, Insightful

    But shouldn't you be using mysql_genuine_advantage_escape_string() instead ;).

    It's stupid stuff like that and "Magic Quotes" that make PHP a sad joke.

    Magic Quotes = mixing input layer filtering with output layer filtering = bad. You tend to get data corruption amongst other things.

    Then there's addslashes and friends.

    PHP: "Making The Wrong Ways Easy, and The Right Ways Hard".

    Oh well, I guess php6 is where they are finally trying to do things right now.

    All the pain is because php coders were doing things terribly wrong in the first place. Don't forget the PHP devs were encouraging them to do things wrong for years.

    --
  23. Re:Is this really news? by SanityInAnarchy · · Score: 4, Insightful

    PHP doesn't have any weird syntax like Perl regular expressions---you can do Perl regex, but it is neatly encapsultated into proper strings the way it should be. Regex is never really going to be readable without a separate course learning that. By the time you know regex syntax, a little extra syntax in your language isn't that bad.

    There's no having to manually re-indent dozens of lines of code because you needed to add another nesting level and whitespace is part of the language, etc. And there's no need to do so in any modern programming environment, either. Most text editors these days have ways to re-indent code, uncomment/comment keyboard shortcuts, etc.

    It's just a really clean, lightweight OO language that's exceptionally easy to learn Easy to learn if you already know HTML, I suppose. But where's my actual, interactive PHP shell that I can play with while I'm learning the language?

    OO? Only recently.

    Clean? Not even close, not when you've used a real OO language.

    and happens to integrate very well with HTML. So does everything else, now. I'd argue Ruby is actually better at this than PHP.

    Don't get me wrong, PHP has plenty of weak points when it comes to performance My language of choice right now is Ruby, so I don't really care about that.

    availability of modules to do various obscure things Considering the amount of crap built-in to the language, I doubt that's a huge stumbling block, either. I like CPAN, but it does help when the language itself is clean enough that I'll happily write a library of my own. But most that I'd need to do with a C library has bindings everywhere I really want to do it.

    mainly because it isn't a kitchen sink like Perl I think Perl has too many built-in functions, available everywhere, completely un-namespaced, compared to Ruby.

    But you know what? Perl has a little over two hundred functions in the main namespace. PHP has a little over three thousand, according to this page.

    So, it may not have the kitchen sink in the syntax, but it has the kitchen sink, the bathtub, the plumbing, and the neighbor's shower in the core library.

    Finally, I call BS on this:

    Almost any code written in C (or C++ without templates/exceptions/other icky stuff) can be trivially ported to PHP by replacing the type names with "var" and adding dollar signs in the right places. (I'm exaggerating slightly, but not much.) Is there a language, other than Python, that this isn't true of, for very simple, "Hello World" or "My first HMAC implementation" examples? Sure, the rules would be different, but dropping all the type declarations (swapping for "var") and adding dollar signs is significant.

    Oh, and does PHP support structs? What about function pointers? I doubt it's "almost any code". It's easy when you understand both C and PHP, but again, I assert that's true for many languages, particularly popular web scripting languages.
    --
    Don't thank God, thank a doctor!
  24. Re:Is this really news? by moderatorrater · · Score: 4, Interesting

    Can you be more specific about how PHP "has a focus" on Web scripting PHP was made originally to program web pages and, while it's been expanded to other uses, its main focus is still web pages. $_GET, $_POST, $_SESSION, $_COOKIE, and $_REQUEST are (as far as I know) unique to PHP in being built into the core of the language. As frustrating as it sometimes is, PHP files are considered standard output unless they have tags enclosing them, whereas in perl everything is considered code unless stated otherwise.

    Loose typing and non-strict syntax in general is particularly well suited to the internet because each request generates a completely new environment. Something that was wrong with the previous request, unless specifically stored, doesn't affect the next request. Strictness in programming stems from the need to keep far flung parts from affecting each other; the web is modular by nature and thus resistant to wide spread bugs. Thus, loose typing and other, less strict forms of programming that make life easier at the expense of fragility is counterbalanced by the modular nature.

    Many won't agree with that analysis, and that's fine. Sloppy coding has gotten more than one web project in trouble, and more than one feature of PHP's that was intended to make life easier ended up going to far and introducing security holes. But that doesn't change the simple fact that PHP was made for the web and has conveniences built into the core that other languages either don't have or require an add on for.
  25. Why PHP does NOT suck by mcrbids · · Score: 3, Insightful

    I've worked with PHP professionally, building a healthy, heavily profitable, and rapidly growing company providing information management services to schools.

    From the simple standpoint of "concept to implementation" - PHP ROCKS. It's very, very fast, requiring little in the way of "planning" and "structuring" while letting the features come out... FAST. It is, bar none, the best RAD environment I've yet worked with. Not that it's the best in every area, but that it clearly has the best balance between features and "gotchas". It has its weaknesses, such as lousy error reporting, but even that can be largely mitigated with a little intelligence in advance. But it really does have a number of key strengths that I leverage to the hilt:

    1) Stability. It just doesn't die. Ever. I've never, ever, ever had a problem with PHP "not working". I don't troubleshoot it. It's there, it works, and I don't sweat it.

    2) Scalability. It's "share nothing" approach makes clusting and random-host selection boil all the way down to a simple session manager. Having 1 or 10 application servers running side-by-side is almost trivial!

    3) Code density = excellent! It's a fairly dense language, meaning that lots can get done in a few lines. Just for giggles, I've written a self-forking, multi-process daemon with a process manager and hundreds of managed children forks performing a deep-level network scan in like 50 lines!

    4) Security. Yes, you heard me correctly. Although you can certainly use PHP "wrong", you can also use it "right". Once you do, you discover that PHP has a number of features that make things like SQL injection and shell parameter expansion a thing of the past. Really. Learn your tools!

    5) Flexibility. You can run it as a module inside Apache. You can run it as a standalone executable. With tools like Ion Cube and PHP-GTK, you can create a cross-platform GUI application without revealing source.

    6) Availability. Any $5/month web hosting company supports PHP, and there are many free ones, as well. You can download a CD, install Linux, and have PHP/Apache up and running in under 10 minutes. There are batrillzions of apps available A LA SourceForge for free. PHP is the most commonly available web development language. And, by no means is it a web-only development language!

    Sorry you can't handle a few quirks in the function names. (so write out a file of wrapper functions - DUH!) Sorry that it's attempts to simplify variable management weren't perfect. Geez. Just code in c and be done with it, why don't you?

    In short, PHP is everything that VB and .NET wished to be, only cross-platform. It's an excellent tool for developing information-processing applications, very, very rapidly. Yes, it has its weaknesses, and nobody's forcing you to use it, and the devs are working on the weaknesses, too. Go use Ruby if it makes you feel good. But PHP works well on Windows, Mac, Linux, BSD, and many others. Seriously: you really can't go too wrong betting on PHP unless you need 3D graphics!

    --
    I have no problem with your religion until you decide it's reason to deprive others of the truth.
  26. Re:Magic Quotes Removed by WWWWolf · · Score: 3, Insightful

    So does this mean that if you are using magic quotes and you upgrade to PHP6, suddenly you will become vulnerable to SQL injection attack?

    "The Management would like to announce that we're switching to slot-loading CD-ROM drives next week. We will be reserving more burn ointments in the first aid room for the next week or so and the janitor has been instructed to stock extra tissues in the bathrooms, but people who have been using CD-ROM drives as coffee cup holders should seriously stop using them as coffee cup holders ASAP."

    Magic quotes did the wrong fix that incidentally happened to work for some people. The problem was that people had been concatenating (unprocessed) parameters to SQL queries; the right solution would have been to process the quoting in the place where it's supposed to be processed (query parametrisation, right before the query actually goes to the DB, automagically using the method that works appropriately for the DBMS in question), but instead, the developers just said "well, we're letting you continue your dangerous way of coding, here's a band-aid fix".

    I've viewed magic quotes as a feature for legacy code that seriously needs to be fixed: "people used to code completely freaking headlessly back in the day because we didn't have real security back then and this was the ONLY way to do things - this feature is a temporary security feature so that they have time to port their utterly reeking PHP3-era string concatenation crap to use DB-specific quote calls or, far better yet, PDO and prepared statements." Using prepared statements makes the code look more manageable and more in line with the stuff you see in other programming languages, which have used prepared statements for a long time now - porting old code over is more than entirely justifiable.

  27. Re:Is this really news? by Dogtanian · · Score: 3, Insightful

    it's not like writing your own string library is any monumental task. Your string library still looks somewhat clumsy, particularly for small projects. And I note that your functions only concatenate two strings; what if you want to stick a few together at once? (Yes, you could use var-args, but what's the checking like on that)

    What if you want to append a number to a string? Given that standard C doesn't support overloading, would you have to write a new *differently-named* method? It'd be a nuisance to have to keep track of all the different methods when (e.g.) PHP can simply do the whole lot using the '+' operator.

    it's a scripting language, it makes no sense to resemble C in any respect. Wrong; it makes perfect sense to use C-style syntax. That's almost certainly the most common syntax by far, used as it is in C++, Java, JavaScript, C# and many other languages.

    Visual Basic's syntax is different, and I had to learn this all over again when I used it for the first time, because I'm used to C-influenced languages. The mental context switch required and my tendency to keep inadvertantly using C-style syntax (leading to syntax errors) is a PITA.

    I wouldn't mind if the VB syntax was nice to begin with, but it's not. It's inelegant and clunky; probably not bad considering it was derived from BASIC, but still inelegant and clunky. It probably got that way because it mutated from BASICs MS-DOS/PC programmers were familiar with, carrying them along with it. However, if (like me) you're not already used to that flavour of BASIC and haven't even used BASIC for years, it's not easy to use at all. It's not even that much like the old BASICs I used to use. Though this is getting away from the main point...

    There may be valid reasons for using a different syntax, but those should reflect underlying differences in the structure/approach of the language (even Perl syntax is somewhat C-flavoured in various respects). However, using a fundamentally different syntax just for the sake of it is a Bad Idea. PHP is easier to use because it has a C-derived syntax.
    --
    "Slashdot - News and Chat Sites Deviant". (Click "homepage" link above for details).
  28. Re:Magic Quotes Removed by 615 · · Score: 3, Funny

    Actually, undoing magic_quotes is quite a bit more involved. Some things to consider:

    • - magic_quotes affects more than just GET, POST and cookie data
    • - GPC data may contain arrays
    • - magic_quotes doesn't process the keys of top-level arrays

    Here's an excerpt from my personal library that addresses these issues and more. It works in PHP 4+ (I forget which minor version). Just give me some credit if you use it!

    // magic_quotes_runtime is _like_ magic_quotes_gpc/sybase, except that it
    // applies to return data (from functions)
    ini_set('magic_quotes_runtime', '0');

    // magic_quotes_gpc/sybase cannot be preempted like magic_quotes_runtime; if
    // either is enabled, the damage is already done
    if (ini_get('magic_quotes_gpc') === '1' || ini_get('magic_quotes_sybase') === '1') {
    /**
    * @author Adam Siler <amsiler@icglp.com>
    * @param mixed $value
    * @param bool $top
    * @return mixed
    */
    function undo_magic_quotes($value, $top = true) {
    // unescape strings
    if (is_string($value)) {
    // stripslashes is magic_quotes_sybase-aware
    return stripslashes($value);
    }
    // recurse into arrays
    elseif (is_array($value)) {
    // as described here: <http://us.php.net/manual/en/security.magicquotes.disabling.php#71817>,
    // magic_quotes_gpc (sybase?) does not escape the keys of top-level
    // arrays

    $unescaped_array = array();

    foreach ($value as $key => $array_value) {
    if (!$top) {
    $key = stripslashes($key);
    }

    $unescaped_array[$key] = undo_magic_quotes($array_value, false);
    }

    return $unescaped_array;
    }
    // return other values unaltered
    else {
    return $value;
    }
    }

    $_GET = undo_magic_quotes($_GET);
    $_POST = undo_magic_quotes($_POST);
    $_COOKIE = undo_magic_quotes($_COOKIE);
    $_REQUEST = undo_magic_quotes($_REQUEST);
    $_ENV = undo_magic_quotes($_ENV);
    // etc.

    // other scripts may check the value of magic_quotes_gpc or
    // magic_quotes_sybase and conclude, incorrectly, that GPC data is escaped.
    // this should fix that
    ini_set('magic_quotes_gpc', '0');
    ini_set('magic_quotes_sybase', '0');
    }