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
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.

 

ok cool, nice answer. thanks :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.