Variables are used to store values, such as numbers, strings, or the results of functions, so that we can use them multiple times in our scripts. Variables are used to store values, such as numbers, text strings, or arrays.
Once a variable is set, we can use it repeatedly in the script.
All variables in PHP start with the $ symbol.
PHP code insertion is very intuitive, starting with "".
All variables start with "$", such as "$money". (The definition is easy for people to imagine) When you need to use it, just define it. You can omit the definition of the variable type, and the PHP compiler will automatically choose it for us.
For conditional judgment statements, PHP is similar to C. If (condition A) {process A} is enough, there are also else and elseif. else is used to run processes other than condition A, elseif (condition N....) is the code that is run when other conditions are true.
The following is the code I wrote:
The code is as follows
|
Copy code
|
||||
if.php
$sex = $_POST["sex"]; |
The code is as follows | Copy code |
switch (variable name) { case value 1: code to be executed if expression = label1; break; case value 2: code to be executed if expression = label2; break; default: code to be executed if expression is different from both label1 and label2; } When the value in the variable meets "value 1" or "value 2", execute the code under the two cases respectively, and then remember to separate each "case" with "break;". When the value in the variable is neither "value 1" nor "value 2", the code below "default" is executed. |