In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Most people do not understand the knowledge points of this article "how to use the member method in php", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to use the member method in php" article.
In PHP, member methods, also known as member functions, are used to access the data of the object, defined inside the class, and the syntax is "function method name (parameter..) {[method body] [return return value]}".
This article operating environment: Windows10 system, PHP7.1 version, Dell G3 computer.
The meaning of member method in php
Member method (the member function − is defined inside the class and can be used to access the data of the object)
Simple format:
[modifier] class class name {/ / use the class keyword plus a space followed by the class name [member attribute] / also known as member variable [member method] / also known as member function}
Full format:
[modifier] class class name [extends parent class] [implements interface 1 [, interface 2...]] {[member attribute] / also known as member variable [member method] / also known as member function}
Member attribute
Format:
Modifier $variable name [= default]; / / such as: public $name= "zhangsan"
Note: member properties cannot be expressions, variables, methods, or function calls with operators.
Public $var3 = 1x2; / / incorrect format public $var4 = self::myStaticMethod (); / / incorrect format public $var5 = $myVar; / / incorrect format
Define the method correctly:
Public $var6 = 100; / / normal values (4 scalars: integer, floating point, Boolean, string) public $var6 = myConstant; / / constant public $var7 = self::classConstant; / / static attribute public $var8 = array (true, false); / / array
Common property modifiers: public, protected, private, static, var (obsolete)
Member method
Member method format:
[modifier] function method name (parameter..) {[method body] [return return value]}
Modifiers: public, protected, private, static, abstract, final
Examples are as follows:
The above is about the content of this article on "how to use member methods in php". I believe we all have some understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please pay attention to 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.