Note: Any program, including PHP, is executed in memory when running, and the PHP code needs to be read into the memory to be executed.
[How php runs]
1. Called through the server (such as apache).
2. Called through the command line (no server participation is required because port 80 is not accessed).
[php starting and ending characters]
<!--?php ?-->
<input name="username" type="text" value="<?php echo $user?>" />
【php comments】
PHP’s comments are similar to C language. You can use // and # to comment a single line, and use /* */ to comment multiple lines.
Popular comment standard for PHP: PHPDocumentor style comments.
/** * 求和函数 * * @param $p1 int 被加数 * @param $p2 int 加数 * * @return int 两数之和 */ function func1($p1, $p2){ return $p1 + $p2; }
[php code in html comments]
Multi-line comments use . If php code is nested in it, the php code is actually executed, but the generated html is commented out, so it will not be displayed.
Tip: Be sure to pay attention to this when using comments. Do not comment on php code like this.
【php variables】
1. Overview
1.$name = 'a'; //It is said that the variable name refers to the value a. A variable consists of three parts: name space, value space, and reference space.
Reference refers to the relationship between variable name and variable value.
Tip: $ is not part of the variable name, it is just used to declare that the following is a variable; variables and functions can have the same name. When $ is used, it represents the variable name, and when $ is not used, it is used as the function name.
2.php variable names are case-sensitive.
3. Use the var_dump(
4. Use the unset(
2. Basic Grammar
Value passing: $a = $b; // Value passing is a copy of the value space.
Pass by reference: $a = &$b; //Pass by reference is a copy of the reference space. Modifying the value of a will also modify b.
【GET and POST】
1.GET: Send data to the server through the requested URL.
Syntax: script name?p1=xx&p2=xx&p3=xx
php gets GET data: through _GET array.
2.POST: Generally used for form submission.
php gets POST data: through the _POST array.
Achieved by sending a data body to the server.
【Simple form GET and POST submission】
Front end:
Backend:
<!--?php echo "get:"; var_dump($_GET); echo "<br-->post:"; var_dump($_POST); ?>