Section 13.7. Other Compatibility Problems


13.7. Other Compatibility Problems

In addition to the problems discussed so far that relate to migrating OO code to PHP 5, some other changes break backward compatibility. Most of them are harmless, but it's better to be aware of them.

13.7.1. Command-Line Interface

The name of the CGI binary file for Windows has changed. This change has no effect on scripts, but rather on the setup of a Windows server running the CGI version of PHP. The CGI executable is now called php-cgi.exe rather than php.exe.

In addition, the location of the CLI executable changed. It was previously located in the CLI subdirectory in the distribution (cli/php.exe), but it's now located in the main directory, the same directory with php-cgi.exe.

Besides this name change, the CLI interface will always have the $argc and $argv variables available.

13.7.2. Comment Tokens

The PHP parser changed the way comments in scripts are parsed. The change allows the parsing of PHPDoc(umentor) comments (/** */).

The singleline (//) and multiline (/* .. */) comments generate the T_COMMENT token in both PHP 4 and PHP 5. The new PHPDoc style comments in PHP 5 generate the T_DOC_COMMENT. In PHP 4, the T_ML_COMMENT token was defined, but never used; the T_ML_COMMENT is not defined in PHP 5. See this piece of code for an example of the tokenizer running on PHP 5:

 comment.php <?php     // Single line     /* Multi      * line      */     /**      * PHP Documentor style      */ ?> tokenize.php <?php     $script = file_get_contents('comment.php');     foreach (token_get_all($script) as $token) {         if (count($token) == 2) {             printf ("%-25s [%s]\n", token_name($token[0]), $token[1]);         } else {             printf ("%-25s [%s]\n", "", $token[0]);         }     } ?> 

Here is the output of php tokenize.php (reformatted for clarity):

 T_OPEN_TAG                [<?php\n] T_WHITESPACE              [     ] T_COMMENT                 [// Single line\n] T_WHITESPACE              [\n        ] T_COMMENT                 [/* Mult                             * line                             */] T_WHITESPACE              [\n\n] T_DOC_COMMENT             [/**                             * PHP Documentor style                             */] T_WHITESPACE              [\n] T_CLOSE_TAG               [?>\n] 

13.7.3. MySQL

The MySQL client library is no longer bundled in PHP 5. MySQL is still supported, of course. You will need to use an external library, which was recommended for PHP 4 anyway. You can use either the "old" libmysql 3.23 version, which can only be used for MySQL 3.23 and MySQL 4.0.x, or the new libmysql 4.1 version of the library, which can be used for MySQL 3.23 and MySQL 4. You might ask why not always use the new version? Well, because this library is licensed under the GPL, while the old 3.23 version is licensed under the LGPL. The new license might cause problems for you if you are distributing your PHP application. If you want to use the MySQLi extension, you can only use the new 4.1 version of the MySQL client library. You can use this new extension alongside the old MySQL extension, but only when you use the same (4.1 version) library for both extensions. A sample configure line to do this is

 ./configure --with-mysql=/usr --with-mysqli=/usr/bin/mysql_config 

Tip

See http://www.php.net/manual/en/faq.databases.php#faq.databases. mysql.php5 for some reasons why PHP no longer bundles the library.




    PHP 5 Power Programming
    PHP 5 Power Programming
    ISBN: 013147149X
    EAN: 2147483647
    Year: 2003
    Pages: 240

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net