Home >Backend Development >PHP Tutorial >In those years, the PHP self-increment and self-subtraction operations we have pursued (2)_PHP Tutorial

In those years, the PHP self-increment and self-subtraction operations we have pursued (2)_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 10:27:35840browse

-------------------------------------------------- ---------------------------------------------

Let’s start with an example to highlight the key points.

$a = true;

echo $a++;

echo $a + 1;

$b = 'c';

echo $b++;

echo $b++;

------------------------@chenwei ---------------- ----------------

Do you know the correct answers to the above four outputs? Here are some summarized rules. You can also experiment by yourself.

1. The Boolean type does not participate in the ++ operation, does not perform type conversion and participates in auto-increment. So the first output is 1.

2. Boolean types involved in arithmetic operations such as +, - will automatically perform type conversion, so the second output is 2.

3. The string ++ in PHP represents ascending order, so the third output is c and the fourth output is d.

-------------------------------------------------- ------------------------------------------

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/815974.htmlTechArticle------------------------ -------------------------------------------------- --------------- Let's start with an example to bring out the key points. $a = true; echo $a++; echo $a + 1; $b = 'c'; echo...
Statement:
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
Previous article:Laravel_PHP TutorialNext article:Laravel_PHP Tutorial