In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to call a method in a class by php. It is very detailed and has certain reference value. Friends who are interested must finish it.
In PHP, you can use "- >" to call a method in a class, which refers to the methods and properties of an instance of the class, and is used by the object to execute the method or get the property. The syntax is "$obj- > a".
This article operating environment: Windows10 system, PHP7.1 version, Dell G3 computer.
Php calls a method in a class
In php, you can use "- >" to call methods in a class.
Create a new php file, named test.php, to explain how to call it in php class methods. Use the header () method to set the encoding format of the page to utf-8 to avoid output Chinese garbled.
Create a test class for testing. In the test class, create an out method and within the method, use echo to output the prompt content. Use new to implement the test class and call the out method within the class with "- >".
Open the test.php file in the browser and see the result. You can see that the method in the class is called successfully.
Summary:
1. In the test.php file, create a test class for testing.
2. In the test class, create an out method, and within the method, use echo to output the prompt.
3. In the test.php file, use new to implement the test class and call the out method within the class through "- >".
4. Open the test.php file in the browser and view the result. It can be seen that the method in the class is called successfully.
These are all the contents of the article "how php calls methods in a class". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.