Home > Backend Development > PHP Problem > What is the principle of string and number operations in php?

What is the principle of string and number operations in php?

coldplay.xixi
Release: 2023-03-01 20:14:01
Original
3051 people have browsed it

The principle of string and number operations in php is: 1. When a string participates in the budget, the system will automatically convert the string type into a numeric type; 2. When there are no numbers or numbers after the string, When participating in the operation, it will be converted into the value "0"; 3. If there is a number in front of the string, the string will be converted into the number when participating in the operation.

What is the principle of string and number operations in php?

The principle of string and number operations in php is:

1. First of all, emphasize: the " " sign in php It is used as an operation, and the operation result must be a numerical value, not like the " " sign used for splicing in JS.

2. Secondly: when a string participates in the budget, the system will automatically convert the string type into a numeric type; when the string type is converted into a numeric type, its value mainly depends on whether there are numbers in front of the string.

  • When there are no numbers or there are numbers after the string (such as: $x="abc"), it will be converted into the value "0" when participating in the operation;

What is the principle of string and number operations in php?

  • When there is a number in front of the string (such as: $x="1.5abc"), the string will be converted into the number when participating in the operation ;

What is the principle of string and number operations in php?

Related learning recommendations: PHP programming from entry to proficiency

The above is the detailed content of What is the principle of string and number operations in php?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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