This article will introduce to you the problems that PHP novices often encounter, ->, => and:: What are these three guys and what do they do? !It makes me dizzy just looking at it.
It doesn’t matter, let’s give a detailed explanation below. If you have a C and Perl foundation, you will find that these guys have similar functions to some of the symbols in them.
‘- >’ symbolis the “infix dereference operator”. In other words, it is a method that calls a subroutine whose parameters are passed by reference (among other things, of course). As we mentioned above, when calling PHP functions, most parameters are passed by reference. The '->' functions in PHP are just like they are in Perl or C. The following is a simple dereference example:
echo $x->def(); # 输出
The ‘=>’ operator is very common in PHP scripts. Because PHP array functions are rich, we often use arrays because they are very convenient for manipulating 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 "greater than or equal to" symbol for a number, you should use ">=" instead of "=>".
In PHP, "::" is called the range parsing operator, also known as the domain operator
The "::" symbol can be considered to be the same as the one in C language "." is similar, but it is more like the ::class range operator in C (Perl).
php calls internal static members of a class, or calls between classes::
The following is an example:
class A { static $count = 0; static function haha() { // } function diaoyoug() { self::haha(); self::$count; } } a.b.c; /* C语言中的 */ a::b::c(); // C++ 中的函数 $a::b::c; # Perl 5中的标量
"=== "(Triple equal sign)
Some people may have doubts. In addition to judging whether the two variables are equal, this symbol will also judge whether the value types are consistent. If the value types are different, it will Return False, for example: $a="1";//Character type 1 $b=1;//Number type 1 When executing $a===$b;, False will be returned
“->”(minus sign, right angle bracket)
is used in a class to access functions or objects in the class, such as:
do_test(); ?>
"=>"(equal sign , right angle bracket)
Assign a value in the array, for example: $arr=array("one" =>("1"=>10, "2"=>20) , "two"=>2); Then $arr["one"]["1"]=10;
[Related tutorial recommendation: "PHP Tutorial"]
The above is the detailed content of Talk about ->, => and :: symbols in PHP. For more information, please follow other related articles on the PHP Chinese website!