PHP Class object
This is a db.php file, inside is a DB class
Class db{ function &object () { static $db; if (empty ($db)) { $db = new Pgsql (); } return $db; } function query ($sql, $transaction = False) { $db = & Db::object (); Return $db->query ($sql, $transaction); }}
My question is that the methods in the DB class are not static (static), why it can be used in an external PHP file like Db::query (), and Db::object (), which is used internally by himself, I wonder why? is not a static method to use it??
Ask the great God pointing twos!! Thank you here first!
Reply to discussion (solution)
This is PHP4 code.
PhP4 don't have that much restraint.
This is PHP4 code.
PhP4 don't have that much restraint.
This is PHP4 code.
PhP4 don't have that much restraint.
This is PHP4 code.
PhP4 don't have that much restraint.
My PHP environment is more than 5.2, it is also support PHP4 code??
PHP5 can be conditionally accepted PHP4.
PHP 5.2 is basically consistent with PHP4, except that objects are always passed by reference, without the use of claims &
Non-static methods cannot be used statically when PHP 5.3 turns on e_strict level error checking
PHP 5.4 Turns on e_strict level error checking by default and cannot statically use non-static methods