Home > Backend Development > PHP Tutorial > php5 两个调用符号(->) 最后被调用的函数座落哪里

php5 两个调用符号(->) 最后被调用的函数座落哪里

WBOY
Release: 2016-06-13 12:03:32
Original
876 people have browsed it

php5 两个调用符号(->) 最后被调用的函数位于哪里?
$app = JFactory::getApplication();
$app->login();

最后这个login()函数有什么特点 在哪个类中能找到,应该怎么找到这个函数的源代码?

JFactory::getApplication();源代码大概如下:完全没有看出login这个函数和getApplication函数有什么关系 

<br />abstract class JFactory {<br />	public static function getApplication($id = null, $config = array(), $prefix = 'J')<br />	{<br />		if (!self::$application)<br />		{<br />			if (!$id)<br />			{<br />				JError::raiseError(500, 'Application Instantiation Error');<br />			}<br /><br />			self::$application = JApplication::getInstance($id, $config, $prefix);<br />		}<br /><br />		return self::$application;<br />	}<br />}<br />
Copy after login

------解决方案--------------------
JFactory 是抽象类,本身不可实例化
所以必定有类继承他
因此所有 class XXXXX extends JFactory 都有可能
------解决方案--------------------
JFactory 看名字应该是个工厂
JFactory::getApplication 根据参数返回一个对象指针
self::$application = JApplication::getInstance($id, $config, $prefix);
$app具体属于哪个类,去JApplication::getInstance这里找吧

------解决方案--------------------
IDE 工具 CTRL+点击 会跟踪到这个方法上...

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