Take you two minutes to understand the operators in PHP

烟雨青岚
Release: 2023-04-09 07:16:02
forward
1893 people have browsed it

Take you two minutes to understand the operators in PHP

(1) Arithmetic operator

Take you two minutes to understand the operators in PHP

".$no."的座位在第".$line."排第".$row."个位置";?>
Copy after login

(2) Assignment operator

  • "=": Assign the value of the expression on the right to the operand on the left. It copies the value of the expression on the right and gives it to the operand on the left. In other words, first apply for a piece of memory for the operand on the left, and then put the copied value into this memory
  • "&": reference assignment, which means that both variables point to the same data. It will cause two variables to share a piece of memory. If the data stored in this memory changes, the values of both variables will change
"; // 我在慕课网学习PHP! echo $c."
"; // 我天天在慕课网学习PHP! ?>
Copy after login

(3) Comparison operator

Take you two minutes to understand the operators in PHP

 $b); // false var_dump($a !== $b); // true var_dump($a < $b); //false $c = 5; var_dump($a < $c); //true var_dump($a > $c); // false var_dump($a <= $c); // true var_dump($a >= $c); // false var_dump($a >= $b); // true?>
Copy after login

(4) Ternary operator

  • ("?:") The ternary operator is also a Comparison operator
  • Expression (expr1)?(expr2):(expr3), if the value of expr1 is true, the value of this expression is expr2, otherwise it is expr3.
= 60 ? "及格": "不及格"; echo $b;?>
Copy after login

(5) Logical operator

Take you two minutes to understand the operators in PHP

(6) String linker

  • Concatenation operator ("."): It returns the string obtained by appending the right parameter to the left parameter
  • Concatenation assignment operator (".="): It Append the right parameter to the left parameter
"; echo $b."
"; echo $c."
"; ?>
Copy after login

(7) Error control operator

  • An error control operator is provided in PHP "@", for some expressions that may cause errors during operation, we do not want to display error messages to customers when errors occur, which is not user-friendly.
  • You can place @ in a PHP expression Previously, any error messages that might be generated by the expression were ignored
  • If the track_error (this thing is set in php.ini) feature is activated, any error messages generated by the expression are stored in variables In $php_errormsg, this variable will be overwritten every time an error occurs, so if you want to use it, you must check it as soon as possible
  • It should be noted that: the error control prefix "@" will not block parsing error information, and cannot Put it before the definition of a function or class, and it cannot be used for conditional structures such as if and foreach.
Copy after login

Thank you for reading, I hope you will benefit a lot.

This article is reproduced from: https://blog.csdn.net/sinat_35615296/article/details/78813100

Recommended tutorial: "php tutorial"

The above is the detailed content of Take you two minutes to understand the operators in PHP. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!