PHP tags
1.<?php?> (recommended)
2.<script language= "PHP" ></script>
3.<?>
4.<%%>
PS: Third and fourth need to be opened in PHP config file to use
PHP Comments:
Single-line Comment
Multi-line comments
Document comments
PHP variables
Variable names are case-sensitive
The variable name must be preceded by a letter or underscore, and then made up of a number, letter underline
You cannot have special characters in the middle of a variable name except underline
Cannot use keywords and reserved words
The variable name is defined in $ and does not need to declare the data type of the variable
Assignment of PHP variables
Value assignment $a = ' Hello '
Reference value $b = $ $a;
Variable $demo = ' Hello '; $ $demo = ' world '; = = ${$demo} = $hello = ' World ';
PHP Hyper-Global variables
$_server $_post $_get $_cookie
PHP Constants
Constants are values that cannot be modified throughout the script
Constants use the Define function to define
1. Constant name: General constants are uppercase
2. Value: The value of a constant cannot be modified once defined
Constants are divided into two types: Custom constants, built-in constants
Built-in constants are constants and magic constants defined by the system default
System-defined constants:
Eg:1. M_PI:
Operating system where the 2.php_os:php executes
3.php_version:php version
4. Maximum value of the php_int_max:php integer
PS: These are the common system-defined constants for PHP comparison
Magic constants: In fact, only the form of constants. But there is no constant "constant", its value will actually change, is only a few of the few:
Eg:1._file_ the current script path
2._line_ currently in the row
3._function_ the name of the current function
4._class_ Current class name
5._method_ the name of the method inside the current class
PHP double quotes and single quotes and delimiters
Single quote: Parse fast
Double quotes: Variables inside double quotes can be replaced
Delimiter: The variable inside the delimiter can be replaced, but there must be no space in the end line where the delimiter is located. eg
$demo 3 = <<<dof
$demo ASDASD
Sdfdg
Dfgfdgdgdf
DOF;
DOF: Custom Name
There must be no space behind the DOF.
Data Types for PHP variables
1. Overall Division:
There are 8 data types in PHP
1. Basic type (scalar type)
- Integer type: int integer.
- Floating-point type: Float,double,real.
- String: string;
- Boolean type: Bool,boolean
2. Composite type:
1. Array type
2. Objects: Object
3. Special types
- Empty type: null, such a type has only one data, that is null.
- Resource type: resource, such as a connection resource for a database.
PHP First Day