Google

Saturday, April 25, 2009

Future of Web Development with Hypertext Preprocessor V6

"Future of Web Development with Hypertext Preprocessor V6"



Are you ready for PHP V6? If you were upgrading tomorrow, would your scripts execute just fine or would you have work to do?



With the "PHP 6 Developers Meeting Notes" out I finally took a while to go and read through them and figure out what is the best way to move forward and start writing code that will be compatible not only for 4x and 5x but continue on though 6x.



New PHP V6 features




  • Unicode support:
    The primary alteration in PHP6 is support for Unicode(

    "Unicode is a computing industry standard allowing computers to consistently represent and manipulate text expressed in most of the world's writing systems.An encoding scheme that allows for virtually all major world languages to be encoded into a single character set. " )

    Much improved for PHP V6 is support for Unicode strings in many of the core functions. This new feature has a big impact because it will allow PHP to support a broader set of characters for international support. So, if you're a developer or architect using a different language, such as the Java™ programming language, because it has better internationalization (i18n) support than PHP, it'll be time to take another look at PHP when the support improves.


  • Namespaces:
    Namespaces are a way of avoiding name collisions between functions and classes without using prefixes in naming conventions that make the names of your methods and classes unreadable. So by using namespaces, you can have class names that someone else might use, but now you don't have to worry about running into any problems.


  • Move XML extension :
    The XMLReader and XMLWriter extensions will move into the core distribution and will be on by default.


  • Move Fileinfo exntesion :
    The extremely useful Fileinfo exntesion will move into the core distribution and enabled by default.


  • Static Binding :
    A new keyword will be created to allow for late static binding - static::static2(), this will perform runtime evaluation of statics.


  • FastCGI always on :
    The FastCGI code will be cleaned up and always enabled for the CGI SAPI, it will not be able to be disabled.


  • 64 bit integers added :
    64 bit integers added(int64), no int32(it is assumed unless you specify int64).


  • "break" keyword extended :
    break keyword will be extended with a static label - so you could do 'break first' and it'll jump to the label first: in your code.


  • foreach multi-dim arrays :
    foreach multi-dim arrays - you'll be able to foreach through array lists, i.e. "foreach( $a as $k => list($a, $b))".


  • {} vs [] :
    You can currently use both {} and [] to access string indexes. But the {} notation will raise an E_STRICT in PHP5.1 and will be gone totally in PHP6. Also the [] version will gain substr and array_slice functionality directly - so you could do "[2,]" to access characters 2 to the end, etc.


  • E_STRICT merges into E_ALL :
    This is quite a serious one! E_STRICT level messages will be added to E_ALL by default. This shows a marked move by the PHP team to educate developers on 'best practises' and displaying language-level warnings.


  • dl() only enable it when a SAPI(Server API) layer registers it explicitly



  • Make "var" an alias for "public" and remove the warning for it




Things removed from PHP V6



In addition to having new features, PHP V6 will not have some other functions and features that have been in previous versions. Most of these things, such as register_globals and safe_mode, are widely considered "broken" in current PHP, as they may expose security risks.



Features that will be removed from the PHP version include:




  • Magic Quotes to go :
    The magic quotes feature of PHP will be going, and as with register globals it's going to raise an E_CORE_ERROR if the setting is found anywhere. This will affect magic_quotes, magic_quotes_sybase and magic_quotes_gpc.


  • Register Globals to go :
    It will no longer be an ini file setting, and if found it will raise an E_CORE_ERROR,finally break all PHP3 era scripts with no recourse at all but to re-code it.


  • Register Long Arrays to go :
    Remember the HTTP_*_VARS globals from yesteryear? Well if you're not already using $_GET, $_POST, etc - start doing so now, because the option to enable long arrays is going (and will throw an E_CORE_ERROR).


  • Safe Mode to go :
    This may please developers who have web hosts that insist upon safe mode! But it will now go totally, again raising an E_CORE_ERROR if found. The reason is that apparently they felt it gave the 'wrong signal', implying that it made PHP secure, when infact it didn't at all. open_basedir will (thankfully) be kept.


  • Short php tags :
    Microsoft Active Server Pages (ASP)-style tags — the shorter version of the PHP tags — are no longer supported


  • ereg extension :
    The ereg extension, which supports Portable Operating System Interface (POSIX) regular expressions, is being removed from core PHP support.



  • Return by Reference will error :
    Don't initiate objects with the reference operator(E_STRICT error)



  • Stop Freetype 1 and GD 1 support
    Stop Freetype 1(TrueType rendering engine library) and GD 1(dynamic creation of images library) support




Some of the features mentioned here have also been ported to PHP V5.3, so that when you move to V6 of PHP, it'll be less of a jump.
The following list of features have been back-ported to V5.3, such as - " Namespaces"




Conclusions



That is about all If you are still using php4 to php5 compatibility, you might want to think about removing PHP5 in the coming months since there is already 6.0 dev versions out. Yes I know you guys do not like to give up your old ways(adoption of PHP6 even slower than that of PHP5 becuase of no backward compatibility) but it is time to move on.



Now PHP is becoming closer to enterprise apps. PHP6 is not a software revolution, but rather a standards evolution, which is sometimes more important in enterprise applications.