Jump to content

[SOLVED] using magic methods


sasori

Recommended Posts

when using magic methods such as __get and __set

is it ok to declare them with the use of modifiers such as private, public,protected and etc..?

like for example,

 

public function __get($property);

 

public function __set($property, $value);

 

or am i wrong? and the correct usage is like

 

function _get()

function _set()

 

with no modifiers in the beginning of declaration..

(am confused about this magic stuff)

Link to comment
https://forums.phpfreaks.com/topic/119264-solved-using-magic-methods/
Share on other sites

If you're confused about magic methods, see here. They're going to need to be public, since they'll need to be called from outside the class. The default is public, so you don't need the public keyword, but it's probably a good habit to have.

If you're confused about magic methods, see here. They're going to need to be public, since they'll need to be called from outside the class. The default is public, so you don't need the public keyword, but it's probably a good habit to have.

 

ok cool, nice answer. thanks :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.