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

iphone - How do I make a UIPickerView in a UIActionSheet -

java - Is there an object like a "Set" that can contain only unique string values, but also contain a count on the number of occurrences of the string value? -