PHP and Mysqlweb application development core technology-Part 1 Php Basics-1 start to learn about php. if you want to learn php, you can refer to the basics. 1.1 First php
The code is as follows:
My First PHP Program
Echo "Hello Everybody! ";
?>
Additional: phpinfo () function usage
1.2 enter the php script
1.2.1 mark the php code section
1.2.2 statements and comments
/**/
//
#
#
1.2.3 mix of php and html
1.3 How to store data
1.4 input the basic data type of php
1.4.1 number: (integer (int) and floating-point number (float) 8 digits indicate that 0 (zero) must be added before the number, and 0x must be added before the number in hexadecimal notation.
Note: During the 1 floating point operation, only the approximate value is obtained.
2 5/2 = 2.5 use the round () function to take an integer
1.4.2 string
Single quotes: ''. to include single quotes in a string, you only need to add a backslash before it.
The simplest way to define a string is to enclose it with single quotes (punctuation marks ').
To output a single quotation mark, you must add a backslash (\) before it (\). To output a backslash before a single quotation mark or at the end of a string, enter two (\\)
Note: If a backslash is added before any other character, the backslash is directly output.
Double quotation marks ""
Escaped characters escape character Meaning
\ N line feed (LF or 0x0A (10) in ASCII)
\ R press 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 form feed (FF or 0x0C (12) in ASCII) (since PHP 5.2.5)
\ Backslash
\ $ Dollar tag
\ "Double quotation marks
\ [0-7] {} the string that matches the expression order is an octal character
\ X [0-9A-Fa-f] {} the string that matches the expression order is a hexadecimal character
1.5 some very useful functions
1.5.1 nl2br: insert an html line break in the output of each new line (\ n) of the string
The code is as follows:
Echo nl2br ("foo ISN'T \ n bar ");
?>
1.5.2 var_dump: view the type and variable value
1.5.3 print_r: returns the result to a string instead of outputting the result to the output stream. This user-friendly output is particularly useful for objects and arrays.
Print_r () displays easy-to-understand information about a variable. If the value is string, integer, or float, the variable value is printed.
If array is provided, keys and elements are displayed in a certain format. Objects are similar to arrays.
1.5.4 var_export: it is similar to var_dump, but its output is actually a valid php code representation of the provided data value.
The code is as follows:
$ Arr = array (1, 2, 4 );
Var_exprot ($ arr );
?>