PHP7 New Operator Usage Example analysis

Source: Internet
Author: User
Tags php programming
This example describes the PHP7 new operator usage. Share to everyone for your reference, as follows:

NULL merge operator

is actually the transformation of the ternary operator, reducing the amount of code

Original practice//$lig = Isset ($_get[' Lig ') "$_get[' Lig ']: ' bee '; $lig = $_get[' Lig ']?? ' Bee '; echo $lig;

Run as follows:

Spaceship operator (combination comparer)

The essence is the size of the comparison, but compared to the ' < ', ' > ' return value more than 1, and Java string comparison CompareTo () function similar

<?phpecho 1<=>1.1;print (PHP_EOL);//Line break echo "<br>";p rint (1.1<=>1); echo "<br>"; Echo 1< = ' 1 ';

Run as follows:

I hope this article is helpful to you in PHP programming.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.