开发者

Do these two PHP OOP syntaxes yield the same result?

In PHP, is:

$objectVar = someClassName::someFunction($var);

the same as:

$object =开发者_如何学JAVA new someClassName();
$objectVar = $object->someFunction($var);


No.

$objectVar = someClassName::someFunction($var);

Here, someFunction is a static method; i.e. it belongs to a class, not an object.

$object    = new someClassName();
$objectVar = $object->someFunction($var);

In this code, it is an instance method that should be accessed through an object.

The result could be the same, but the handle used to call the method is different.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜