php - calling member variables of class from normal method -
i seek phone call fellow member variable of class within method of same class.
if phone call straight doesn't work, requires utilize $this. there reason this? can't class realize variable calling belongs it?
the reason more or less because that's how php works. sounds used java automatically uses instance members in current scope if there not local variable overrides fellow member in same scope. php not grant liberty:
class x { private $y = 'r'; public function z() { $y = 'q'; echo "$this->y\n"; //r echo "$y"; //q } } in java, still have utilize this.y in above illustration print r because class fellow member name has been overridden locally. imagine php's members always overridden in methods void.
php
No comments:
Post a Comment