Lately I've been looking into PHP 6 and what it has to offer. I am trying to find out things that a developer has to understand in order to support PHP 6. So far I have noticed that:
1) Unicode aware functions
In PHP 6, all functions are Unicode aware. This can lead to problems when you use functions in non-Unicode way like:
Code: Select all
echo strlen(file_get_contents('binary_file.bin')); // 32
echo filesize('binary_file.bin'); // 402) Character code point access
Code: Select all
$a = "??";
echo $a[1]; // will output ? - not the byte[1] I am not entirely sure, but is there a way to disable Unicode semantics? Also, as far as I know - the encoding used for functions is determined by the script encoding? Does this mean that if index.php is UTF-8 which includes binaryProcessor.php which is ASCII - the functions in binaryProcessor.php will not use UTF-8?
3) Namespaces
It seems that the separator for namespaces is going to be the stupid \ character. So, a class like
Code: Select all
class MyProgram
{
static function MyGlobalFunction() {}
}Code: Select all
MyProgram::MyGlobalFunction();Code: Select all
namespace MyProgram;
function MyGlobalFunction();Code: Select all
MyProgram\MyGlobalFunction();Do you think that it is impossible to program a complex program that works in both PHP 5 and 6? What kind of things are needed to be handled if you are to support both of them? If you support them both, what features of PHP 6 you can't use? Or should I and other developers just wait until PHP 6 is mainstream and switch to it = recode everything and ask potential 3rd party module writers to adapt, too?
All thoughts welcome.
Ah, it seems that you can easily define the encoding to use in a PHP file:
Code: Select all
<?php
declare(encoding="ASCII");
echo strlen("?"); // 3 (bytes)
declare(encoding="UTF-8");
echo strlen("?"); // 1 (character)
?>So, how much do you care about PHP 6? Will you only move to PHP 6 and drop the support for PHP 5 when you see the appropriate time to do so?
One thing that I really would like to know is that when PHP 6 is out?! Next year? 2 years? 5 years? If it takes many years for it to come out, I can stop worrying right now and just concentrate on PHP 5.