PHP is the abbreviation of the English hypertext preprocessing language Hypertext Preprocessor. PHP is an HTML embedded language. It is a scripting language that is embedded in HTML documents and is executed on the server side. The language style is similar to C language and is widely used.
php is a scripting language that can only be run on the browser, unlike java and C# which can be run on the console
This is the php standard format
Let’s start learning Hello world is often used in programming languages
echo "hello,world";
?>
echo is the print in php and will be displayed in the browser
php can be embedded into html code
From a syntactic point of view, PHP language is similar to C language. It can be said that PHP draws on the grammatical features of C language and is improved from C language. We can mix PHP code and HTML code. Not only can we embed PHP scripts into HTML files, we can even embed HTML tags in PHP scripts.
Separate from HTML The following methods can be used:
. . . ?> Not rigorous
Just use this
. . . This is too long. .
This is like asp
About comments
PHP supports C, C++ and Unix style comments:
/* C,C++ Style multi-line comments*/
// C++ style single-line comments
# Unix-style single-line comments
The first two are still used more
echo and print PHP and The simplest interaction of HTML is achieved through print and echo statements. In actual use, the functions of print and echo are almost exactly the same. It can be said that wherever one can be used, the other can also be used. However, there is still a very important difference between the two: in the echo function, multiple strings can be output at the same time, while in the print function, only one string can be output at the same time. At the same time, the echo function does not require parentheses, so the echo function is more like a statement than a function. Let's take a look at the following example:
$a="hello";
$b="world";
echo "a","b";
print "a","b";
?>
will report an error directly
Parse error: syntax error, unexpected ','
So this is the only way
$a="hello";
$b="world";
echo "a","b";
print "a";
?>
The above will print aba
$a="hello";
$b="world";
echo $a.$b;
print $a ;
?>
will print helloworldhello
$a="hello"; is to define a string and add $ before the letter to indicate that it is a variable
And the variable type is determined by php , the key is to see what value you assign to the variable
This is similar to JavaScript's var definition of variables
$Although this form looks a bit awkward, it will be fine once you get used to it. At least you don't need to consider it when defining variables using this Type, there is no need to consider any type conversion, this is much simpler than C language
How to check what type a variable is?
Use var_dump function
$a="hello";
$b=1;
$c=1.1;
$d='h';
$e=true;
echo var_dump($a);
echo var_dump($b);
echo var_dump($c);
echo var_dump($d);
echo var_dump($e);
?>
The result is
The above is the official start of PHP learning (1) For more related content, please pay attention to the PHP Chinese website (www.php.cn)!