Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - As for PHP, isn’t the i in $i here a separate variable? Why do we need to add the $ sign to switch and echo?
As for PHP, isn’t the i in $i here a separate variable? Why do we need to add the $ sign to switch and echo?

PHP is a weak language type, and there is no need to declare the variable type when declaring variables.

For example:

$a = 1;

$a (note that it is a whole, not $a as you said), because 1 is a regular shape, So an integer variable is declared.

$a = '1';

Because '1' is a string (the declaration of a string is to declare it with double quotes or single quotes or delimiters), so $ a is a string type.

So when declaring a variable in PHP, you declare it directly without declaring its type. Which type of variable it belongs to depends on what type of declared value it belongs to.

$ is not used to declare ($+variable name) to represent a variable;

In PHP ($+variable name) = value, declare a variable.