This forum is now read-only. Please use our new forums at discuss.codecademy.com.

For Loops in PHP Forum

View Course

54 points
478038f2d2756db79fb2f01281d8c51f?s=140&d=retro
Submitted by
zigglr
over 1 year ago

Please can someone explain the $this->name = $name function

Please can someone explain this function I really don't understand it:

function __construct($name) {
$this->name = $name;
}

Thanks!


0 votes

permalink

You can imagine $this as a placeholder for future object's name. This function is called when a new object is created, it automatically assign passed parameter $name with the certain object so you can later acces it by calling [object's name]->name.

1288 points
Cd63ccf5369069002b667d4ebf703ac5?s=140&d=retro
Submitted by
sksn
over 1 year ago