PHP and Mysqlweb application development core technologies part 1 Php basics 1 get to know php

  • 2020-05-09 18:19:42
  • OfStack

1.1 the first php
 
<html> 
<head> 
<title>My First PHP Program</title> 
</head> 
<body> 
<?php 
echo "Hello Everybody!"; 
?> 
</body> 
</html> 

Additional: usage of the phpinfo() function
1.2 enter the php script
1.2.1 identify the php code paragraph
1.2.2 statements and comments
/* */
//
#
#
1.2.3 mix php and html
1.3 how to store data
1.4 enter the basic data type of php
1.4.1 digits :(integers (int) and floating point (float)). Base 8 means you must add 0 (zero) before a number, and base 106 means you must add 0x before a number.
Note: when dealing with a floating point number, only approximations are taken
2 5/2 = 2.5 to get an integer use round()
1.4.2 string
Single quotation marks: ", to include single quotation marks in a string, simply put a backslash before it.
The easiest way to define a string is to enclose it in single quotation marks (punctuation ').
To output a single quote, put a backslash (\) before it. To output a backslash before a single quote or at the end of a string, type two (\\)
Note that if you put a backslash before any other character, the backslash will be printed directly.
Double quote ""
Escaped characters escape character Meaning
\n line feed (LF or 0x0A (10) in ASCII)
\r enter (CR or 0x0D (13) in ASCII)
\t horizontal tab(HT or 0x09 (9) in ASCII)
\v vertical tab (VT or 0x0B (11) in ASCII) (since PHP 5.2.5)
\f replacement (FF or 0x0C (12) in ASCII) (since PHP 5.2.5)
\ \ the backslash
\$usd dollar mark
\ "double quotation marks
\[0-7]{1,3} the string in the order of this expression is one character in base 8
\x[0-9A-Fa-f]{1,2} the string in the order of this expression is 1 character in base 106
Some very useful functions in 1.51
1.5.1 nl2br: insert html newline at the output of each new line of the string (\n)
 
<?php 
echo nl2br("foo isn't\n bar"); 
?> 

1.5.2 var_dump: view types and variable values
1.5.3 print_r: returns the result to a string, not to an output stream. This user-friendly output is especially useful for objects and arrays
print_r() displays easy-to-understand information about a variable. If you give string, integer, or float, the value of the variable itself is printed.
If you give array, the keys and elements will be displayed in a format of 1. object is similar to arrays.
1.5.4 var_export: it is similar to var_dump, except that its output is actually a valid php code representation of the data value provided
 
<?php 
$arr=array(1,2,3,4); 
var_exprot($arr); 
?> 

Related articles: