0

I want to create class which will dynamically generate getXXX and setXXX function of all the variable in which this class get extended.

can we use "user call func array" or "user call func"

any example or idea how to do this?

class B extends A
{
 var $name;
 var $email;
 var ....
}

I want some type of coding in class A which will generate get and set method for all the variable in class B in which it is extended.

And also I want to create other methods other than get and set which will use variable name of the extended class

something like this getbyname() or similar function which will use variable of extended class

2

1 Answer 1

1

Getters and setters are a solved problem. You can use the magic __get() and __set() methods.

Know this, there's nothing better than actually implementing all the getters and setters manually! If you have too many, your class probably has too many functions and needs to be split down!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.