PHP learning Notes (1) & nbsp; PHP script with & lt ;? Php starts? & Gt; end. & Lt ;?? & Gt; to start and end the script block. To ensure compatibility, try to use the standard format. PHP usually contains HTML tags, like HTML files, and some ph php study notes (1)
PHP script End. You can use To start and end the script block. To ensure compatibility, try to use the standard format. PHP usually contains HTML tags, such as HTML files and some PHP script code. Below is a simple PHP code,
There are two basic commands for outputting text through PHP, echo and print.
All variables in PHP start with the $ symbol.
The correct method for setting variables is:
$ Var_name = value;
PHP is a loose language. in PHP, you do not need to declare the variable before setting it.
PHP automatically converts a variable to a correct data type based on the method in which the variable is set.
In PHP, variables are automatically declared during use.
In PHP, there is only one string operator.
The concatenation operator (.) is used to connect two strings.
For example:
$txt1="Hello World";
$txt2="nihao";
echo $txt1 . " " . $txt2;
?>
Above code output
Hello World nihao
The strpos () function is used to retrieve a string or a character within a string.
If a match is found in the string, the function returns the first matched position. If no matching is found, FALSE is returned.
For example:
The returned value is 6 (starting from 0)