In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article is about the use of = > and-> and:: symbols in PHP. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
'- >' symbol
Insert dereferencing operator (infix dereference operator). In other words, it is a method that calls a subroutine that passes parameters by reference (and, of course, other functions). As we mentioned above, when calling PHP functions, most parameters are passed by references. The'- > 'functions in PHP are just like they are in Perl or C++. Here is a simple example of dereferencing:
Echo $x-> def (); # output
'= >' operator
The'= > 'operator is common in PHP scripts. Because php array functions are rich, we often use arrays because it is easy to manipulate data.
$phparr= new array (in = > 'reply,'
Side = > 'left'
Padx = > 2m
Pady = > 2m
Ipadx = > 2m
Ipady = > 1m
)
By the way, if you need to use the number "greater than or equal to", you should use "> =" instead of "= >".
:: domain operator
In PHP, this is called the range parsing operator, also known as the domain operator.
The symbol can be thought of as the same as in the C language. Similar, but it is more like the: class scope operator in C++ (Perl).
Php calls internal static members of a class, or calls between classes with::
Here is an example:
Class A
{
Static $count = 0
Static function ()
{
/ /
}
Function diaoyoug ()
{
Self:: ()
Self::$count
}
}
A.b.c; / * in C language * /
Functions in a::b::c (); / / C++
Scalar in # Perl 5
"=" (third class sign)
Some people may doubt that in addition to judging whether the two variables are equal, this symbol will also determine whether the value type is the same. If the value type is different, it will return False, for example: $a = "1"; / / character type 1 $bread1bank / numeric type 1 will return False when executing $astatus.string
"- >" (minus sign, right angle bracket)
Used in a class to access functions or objects in the class, such as:
"= >" (equal sign, right angle bracket)
Assign a value to the array, for example: $arr=array ("one" = > ("1" = > 10, "2" = > 20), "two" = > 2); then $arr ["one"] ["1"] = 10
The usage of = > and-> and:: in PHP explains the usage of 1 and = > in detail.
In php, the array default key name is an integer, or you can define any character key name yourself (preferably with practical significance), such as:
$css=array ('style'= >' 04th green' = > 'color')
Then $css ['style'] = =' 0 green' green' ['color'] =.
2. The usage of->
-> used to reference members of an object (properties and methods)
$arr= ['astats = > 123 bookmarks = > 456]; / / Array initialization echo $arr [' a']; / Array reference print_r ($arr); / / View array class A {public $astat123; public $baud 456;} $obj=new A (); echo $obj- > a Placement / object reference print_r ($obj); / / View object? >
Output result:
123Array (
[a] = > 123
[B] = > 456)
123A Object (
[a] = > 123
[B] = > 456)
3. The usage of:
The double colon operator, the scoping operator Scope Resolution Operator, can access properties and methods overridden in static, const, and classes.
(1) Program List: access outside the class definition with variables
Class Fruit {const CONST_VALUE = 'Fruit Color';} $classname =' Fruit';echo $classname::CONST_VALUE; / / As of PHP 5.3.0echo Fruit::CONST_VALUE;? >
(2) Program List: use: outside the class definition:
(3) Program List: call the parent method
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.