开发者

very simple OOP question

Hopefully a quick and easy clarification only...With th开发者_开发技巧is code found in an action in a controller:

...         
$SaveAccount = new SaveAccount();
$SaveAccount->saveAccount($username, $password, $email);
...

Does the second line mean "run the method "saveAccount()" on the new object? Is that what the -> means? Thanks!


The -> is used with objects. In below line:

$SaveAccount->saveAccount($username, $password, $email);

The saveAccountmethod is run of the object $SaveAccount

I would suggest you to have a look at:

Object Oriented Programming with PHP


Does the second line mean "run the method "saveAccount()" on the new object?

Yes.

Is that what the -> means?

No, it means "fetch the method or property" named saveAccount. Together () it gains the meaning "run the method "saveAccount()". Note: technically, you cannot fetch a method without executing it, so $obj->methodname has no meaning without (), but this explanation may help you conceptually.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜