The PHP script executes on the server and returns the results of plain HTML to the browser.
It sounds very powerful, so PHP is the server-side language. HTML is the front end.
The default file name extension for PHP files is ". php"
So PHP files usually contain HTML tags and some PHP script code.
PHP script starts with <?php> and ends with?>.
PHP scripts can be placed anywhere in the PHP file.
<! DOCTYPE html> echo "Hello world!" ?> </body>
Each line of PHP code must end with a semicolon, which is similar to the C language.
PHP has two kinds of annotation methods, one is a single line comment//
One is multiline comment/* */
Even the notes and the C language are the same.
Both the PHP statement and the PHP variable are case-sensitive.
The PHP variable starts with the dollar sign $, and the rest of the naming conventions are similar to the C language.
The PHP language, like the scripting languages of Perl and Python, is just as good as using variables, without declaring its type.
This is really great.
<? $x=5$y=10function myTest () { global $x,$y; $y=$x+$yecho$y//
The PHP language has global variables, and the variables defined outside the function are global variables, such as $x and $y.
Then to use them inside the function, you must use the Global keyword to declare that these two things are global variables before they can be used, otherwise the use of the OH.
This must be remembered, because it is very useful, because we often need to use global variables when writing programs with functions.
Let's take another look at the code:
<? function myTest () { static$x=0; Echo $x ; $x+ +
See here we see there is a static stuff. What is this, called a static variable?
Here we see that the static variable is 0 when it is first declared.
And what will be the result of our execution? It's going to be 012.
Originally in the function, preceded by a static variable, the function is not destroyed after the end of the run, will continue to retain.
When the function is executed again, the value after the last execution of the function is inherited.
It should be noted here that the initial value must be assigned at the time of Declaration, and who knows what you are if you do not assign an initial value.
PHP Full stack Development (iv): PHP Learning (1. Basic syntax)