PHP string addition
PHP string addition is a basic technique for string processing. Common PHP string addition can be divided into simple string concatenation and numeric string calculation. The concatenation of strings uses concatenation operators. It is the half-shape dot (.). The addition of numerical calculation strings uses the plus sign (+) of the mathematical operator. Let's take a look at the basic syntax of these two PHP string additions, and then apply the examples The actual operation is for your reference.
The basic syntax of PHP string addition
number: number + number
A practical example of PHP string addition
echo'<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'; //Web page encoding
$stringA='25';
$stringB='77'; echo'Add
text string:';
echo $stringA.$stringB ;
echo'<br> Add numeric string:';
echo $ stringA +$ stringB ;
?>
digital string: 102
Note: In PHP, there is actually no special distinction between numbers and text strings, that is, both numbers and text are called strings. The only difference is that numeric strings can be used for calculations. If you are interested in PHP If you are interested in string rules, please refer to the introduction in " PHP String Strings ".
Post a Comment
0 Comments