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
Release: 2016-07-13 10:27:35
Original
852 people have browsed it

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

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...
Related labels:
php
source:php.cn
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