Why can a member method in a DB class in PHP be used as a static method! Please advise? This is a db. php file, which contains a DB class & nbsp; DB {& nbsp; function & nbsp; & amp; object () & nbsp; & nbsp; & nbsp ;{& nbsp; & nbsp; & why can a member method in a DB class in PHP be used as a static method! Please advise?
This is a db. php file, which contains 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);
}
}
I would like to ask why the methods in the DB class are not static and can be used in external php files like DB: query, and the DB: object () that he uses internally, I wonder why? Isn't it a static method ??
Please give me some advice !! Thank you!
------ Solution --------------------
This is the php4 code.
Php4 does not have so many constraints
------ Solution --------------------
Php5 supports conditional acceptance of php4.
------ Solution --------------------
Php 5.2 is basically the same as php4, except that the object is always passed by reference, that is, no declaration is required &
Php 5.3 cannot use non-static methods in static mode when the E_STRICT level error check is enabled
In php 5.4, the E_STRICT error check is enabled by default, and non-static methods cannot be used in static mode.