Why can a member method in a DB class in PHP be used as a static method! Please advise

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.