Analysis on using the PHP logical operator _ PHP Tutorial

Source: Internet
Author: User
Analyze the use of PHP logical operators. PHP is still quite common, so I studied the PHP logical operators and shared them here, hoping to be useful to everyone. PHP is a type of powerful PHP that creates dynamic interactive sites, which is quite common. so I have studied the PHP logical operators and shared them here. I hope they will be useful to you. PHP is a powerful server-side scripting language for creating dynamic and interactive sites.

PHP is free and widely used. At the same time, for competitors such as Microsoft ASP, PHP is undoubtedly another highly efficient option. PHP is extremely suitable for website development. its code can be directly embedded with HTML code. PHP syntax is very similar to Perl and C. PHP is often used together with Apache (web server. However, it also supports ISAPI and runs on Microsoft IIS platform of Windows. String operator, which has two character string operators. The first is the concatenation operator ("."), which returns the string after the left and right parameters are connected. The second is the concatenation of the value assignment operator (". ="), which attaches the parameter on the right to the parameter on the left.

1. string operators

Example:

 
 
  1. php
  2. $a="Hello";
  3. $b=$a."World!";
  4. $a="Hello";
  5. $a.="World!";
  6. ?>

The only array operator in PHP is the + operator. It attaches the array on the right to the array on the left, but duplicate key values are not overwritten.

 
 
  1. $a=array("a"=>"apple","b"=>"banana");
  2. $b=array("a"=>"pear","b"=>"strawberry","c"=>"cherry");
  3. $c=$a+$b;
  4. $ar_dump($c);

After the script is executed, the script displays:

 
 
  1. array(3){
  2. ["a"]=>
  3. string(5)"apple"
  4. ["b"]=>
  5. string(6)"banana"
  6. ["c"]=>
  7. string(6)"cherry"
  8. }

2. PHP logical operators:

PHP logical operators:
$ Aand $ bAnd (logical and) TRUE, if both $ a and $ B are TRUE.
$ Aor $ bOr (logical OR) TRUE, if $ a or $ B is TRUE.
$ Axor $ bXor (logical OR) TRUE, if $ a or $ B is TRUE, but not at the same time.
! $ ANot (logical NOT) TRUE, if $ a is not TRUE.
$ A & $ bAnd (logical and) TRUE, if both $ a and $ B are TRUE.
$ A | $ bOr (logical OR) TRUE. if $ a or $ B is set to TRUE.

"And" and "or" have two different operators because they have different operation priorities.


Bytes. PHP is a strong way to create dynamic and interactive sites...

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.