Variables are containers for storing information
PHP variables
Just like algebra, PHP variables can be used to hold values (x=5) and expressions ( z=x y).
Variable names can be short (such as x and y) or more descriptive (such as carname, total_volume).
PHP variable rules:
Variables start with the $ symbol, followed by the name of the variable
The variable name must start with a letter or an underscore
Variable name Cannot start with a number
Variable names can only contain alphanumeric characters and underscores (A-z, 0-9, and _)
Variable names are case-sensitive ($y and $Y are two Different variables)
Note: PHP variable names are case-sensitive!
The following example demonstrates how PHP creates variables
<?php $txt="Hello world!"; $x=5; $y=10.5; ?>
The above is the detailed content of what are variables in php. For more information, please follow other related articles on the PHP Chinese website!