I used to get used to art and front-end development. Now, I am going to learn PHP at the advanced backend. When I was learning the class, I encountered a private method call problem. The Code is as follows: 1? Php2classPerson {3 publicfunctionsay ($ name, $ age) {4 $ con $ this-get ($ name, $ age); here $ this-is key 5
I used to get used to art and front-end development. Now, I am going to learn PHP at the advanced backend. When I was learning the class, I encountered a private method call problem. The Code is as follows: 1? Php 2 class Person {3 public function say ($ name, $ age) {4 $ con = $ this-get ($ name, $ age ); // here $ this-is key 5
I used to get used to art and front-end development. Now I am going to learn PHP at the advanced backend.PrivateMethodCall problems.
The Code is as follows:
1
Get ($ name, $ age); // here $ this-> is the key 5 echo "my name is:". $ name ."
"; 6 echo" my age is: ". $ age ."
"; 7 echo" get: ". $ con ."
"; 8} 9 private function get ($ a, $ B) {10 $ a = $. $ B; 11 return $ a; 12} 13 14} 15 16 $ person = new Person (); 17 $ person-> say ("ren", 25 ); 18 19?>
This code is very simple. I want to implementInternalPrivateMethod. As shown in row 4th. Js is used to calling get ()MethodIf "$ this" is not added to the front, the program may fail. You can call this function after completing the configuration.