18 June 07
Migration from PHP4 to PHP5
There is a PHP5 php.ini directive that puts PHP5 into PHP4
compatibility mode. In otherwords, your PHP4 scripts will for
sure [most likely] work. This directive is called: zend.ze1_compatibility_mode
If the compatibility mode doesn’t do it, try to reorganize code a little – e.g. constructors needing to be renamed… http://www.ibm.com/developerworks/opensource/library/os-php-v5migr/
Configuring PHP5 with Apache on SLES 10
– after installing Apache, PHP5, mod_php etc Apache
— make Apache start at boot time
— if need be, follow /usr/share/doc/packages/php5/README.SUSE
PHP5 and <? ?>
PHP5 has short_open_tag=off by default, which means that <? ?> and <?= ?> cannot be used. While <?php ?> can be used in place of the first tag, the next one must be replaced by <?php echo ?> which is makes code quite unreadable.
So how about having short_open_tag=on in php.ini?
PHP4 and references
We can use references for arguments and return them from the functions. There are at least a few tricky situations in PHP4 when references work weirdly or not at all:
returning/passing NULL by reference – it doesn’t make sense to do it, but if that happens then (my) PHP4 badly and quietly dies.
$myVariable =& $this→myField→itsFunction() generates a notice even when itsFunction() is defined to return by reference. Only $myVariable =& $this→myFunction() works.
references and global variables don’t really work together. Global variables are generally a bad idea, but sometimes we need them ($_REQUEST, $_SESSION). CakePHP session management doesn’t give access by references (and it it uses $_SESSION by default).
you need to keep track of your reference ‘links’ and when passing/retrieving data by reference you need to make sure that the functions don’t perform undesired/undocumented/unexpected side effects
if typing assignments by reference as =& then it’s easy to search/grep for them – in order to track any funny interaction
PHP mysql connection has its selected DB changed without any obvious reason
– PHP mysql_connect(..) by default reuses a connection if we pass same server, user & password several times.
– If we use those for several DBs then we want to pass an optional FALSE parameter to mysql_connect() to turn off this default behaviour. Or we can use same DB, or to have separate user for each DB.