Home  >  Article  >  Backend Development  >  结象范例化时不加new行吗

结象范例化时不加new行吗

WBOY
WBOYOriginal
2016-06-13 12:09:57843browse

结象实例化时不加new行吗
看到有人这么写$_sxe=simplexml_load_file('text.xml');
这样写到底是函数还是对象呢
------解决思路----------------------
simplexml_load_file 是一个函数
而 simplexml_load_file 返回的数据是一个对象
两者没有冲突啊。

例如:foo是方法,返回的是一个对象。

<br />function foo(){<br />    $ret = array(<br />        'name' => 'fdipzone'<br />    );<br />    return (object)$ret;<br />}<br /><br />$obj = foo();<br />echo $obj->name; // fdipzone<br />

Statement:
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