Home > Backend Development > PHP7 > body text

Let's take a look at the new operators in PHP7

coldplay.xixi
Release: 2023-02-17 16:18:01
forward
3390 people have browsed it

Let's take a look at the new operators in PHP7

##NULL merge operator

is actually ternary Operator transformation, reduced code amount

//原先的做法
//$lig = isset($_GET['lig'])?$_GET['lig']:'bee';$lig = $_GET['lig']??'bee';echo $lig;
Copy after login
Running results:

Lets take a look at the new operators in PHP7

Spaceship operator (combination comparison operator)

The essence is a size comparison operator, but compared to '<' and '>', the return value is -1 more. It has a similar function to Java's string comparison compareto()

<?phpecho 1<=>1.1;print (PHP_EOL);//换行符echo "<br>";print (1.1<=>1);echo "<br>";echo 1<=>&#39;1&#39;;
Copy after login
Run results:

Lets take a look at the new operators in PHP7

Recommended tutorial: "

php video tutorial"

The above is the detailed content of Let's take a look at the new operators in PHP7. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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
Popular Tutorials
More>
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!