Home > Article > Backend Development > What is the principle of string and number operations in php?
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.
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;
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 ;
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!