静态方法调用等价于new对象吗解决方法

WBOY
Release: 2016-06-13 12:19:18
Original
1266 people have browsed it

静态方法调用等价于new对象吗
看别人写的一个例子,似乎使用了静态调用后,就等价于new了一个对象了,不过从道理上怎么也没有理解
这到底是为什么呢

------解决思路----------------------
getDB里面实现了new 实例,返回的就是一个实例,所以就能用query()
静态方法是常驻内存的,调用要快一点,但是里面不能用 $this ,因为只有 new 实例以后才能用 $this
------解决思路----------------------
DB::getDB() 返回了一个 DB 的实例
你看看 getDB 方法的定义就清楚了

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!