For example, I’ve seen third-party applications that have functions like this:
$db->select('columns')->from('table')->where('condition');
That’s just an example. How do you create methods like that?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To accomplish this, each of the methods should return
$this, an instance of the class which contains the methods.inside these methods, you generally perform some kind of modification to the state of the object.