I am wondering what is the difference between $this->name and $this->$name? Also does $this have to be strictly named this or can it be anything?
I am wondering what is the difference between $this->name and $this->$name ? Also does
Share
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.
$thisis a reserved variable name and can not be used for anything else. It specifically points you to the object your are currently working in. You have to use$thisbecause you do not know what variable object will be assigned to.$this->namerefers to the current class’s variablename$this->$namerefers to the class variable of whatever the value of$nameis. Thus