From: Andrey Hristov Date: Sun, 28 Mar 2004 09:30:21 +0000 (+0000) Subject: - Fixed the explanation and example about "classes must be declared before used". X-Git-Tag: php-5.0.0RC2RC1~198 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=58a52b164185fdb467d4ad98c388dcc56b5befb5;p=php - Fixed the explanation and example about "classes must be declared before used". - Added new entry about get_class() (Thanks Lukas for reminding (toStudlyCapOrNotToStudlyCap.txt). --- diff --git a/README.PHP4-TO-PHP5-THIN-CHANGES b/README.PHP4-TO-PHP5-THIN-CHANGES index 9661906925..149772f2e5 100644 --- a/README.PHP4-TO-PHP5-THIN-CHANGES +++ b/README.PHP4-TO-PHP5-THIN-CHANGES @@ -1,5 +1,5 @@ -1. strrpos() and strripos() now use the entire string as a needle. - Be aware that the existing scripts may no longer work as you expect. +1. strrpos() and strripos() now use the entire string as a needle. Be aware + that the existing scripts may no longer work as you expect. EX : barfu(); + $a = new a(); + class a { + } + ?> + + Example 2 (throws an error): + + + Output (example 2) : + Fatal error: Class 'a' not found in /tmp/cl.php on line 2 - class fubar { - function barfu() { - echo 'fubar'; - } +9. get_class() starting PHP 5 returns the name of the class as it was + declared which may lead to problems in older scripts that rely on + the previous behaviour - the class name is lowercased. + Example : + - This script is perfectly valid and works in PHP 4 but with PHP 5 there - will be a fatal error like : - Fatal error: Class 'fubar' not found in .... - If there is defined function __autoload() it will be called. + + Output (PHP 4): + string(6) "foobar" + + Output (PHP 5): + string(6) "FooBar" + ---------------------------------------------------------------------- + Example code that will break : + //.... + function someMethod($p) { + if (get_class($p) != 'helpingclass') { + return FALSE; + } + //... + } + //... + Possible solution is to search for get_class() in all your scripts and + use strtolower(). + + \ No newline at end of file