oop - $this variable in PHP -


I have just started acquainting with PHP's OO attributes, and I ask you something about First of all, if the class I'm using in the $ this keyword is not defined property variable foo , then its This means that the following code is being used:

  $ this-> Foo = 5; Echo $ this-> Foo;  

Will create the foo property on the runtime, like in JavaScript? What is the visibility of this property?

Yes, this foo

you can easily Can check: php square fu {public function setFoo ($ foo) {$ this- & gt; Foo = $ foo; }} $ F = new Foo (); $ F & gt; SetFoo (5); Echo $ f- & gt; Foo;

Will print with 5 errors.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -