Lecture 1: Start learning PHP 2016/5/2 20:29
What can PHP do? www website management system; websever wap website
Lecture 2 PHP data type source code debugging 2016/5/2 20:30
PHP and HTML mixed The sentence ends with ; English half-width semicolon~! !
In PHP, it starts with and ends with ?>;
echo is the output
print is to print a string
print_r is to print a composite type such as an array object
print has a return value but echo does not
Variables are defined with the $ dollar sign, and strings are defined with double quotes "" or single quotes ''
Difference: Double quotes support all escape characters such as carriage returns, etc. and also support the output of custom variables eg: echo "variable $a" and Single quotes only support simple escaping;
array array:
array definition $arr=array(5,6,5,9,8);
title"=>3);
Output the first value in the array eg: echo arr[0]; Then
use is_array($arr) to determine whether it is an array. If so, return true, otherwise return false
explode "split function" eg: $a="1000-2000-3000"; $arr=explode("-",$a); that is, use "-" to split $a and store it in the array $arr
Use foreach to traverse the array
Advantages of foreach: You don’t need to know how many records there are in the array{Compared to using for to traverse, for needs to count the length of the array first and then set the number of loops, while foreach can traverse all of them directly}
Use Example:
$arr=(1980,1982,1984,1988);
foreach($arr $key=>$value){
echo $value; //&key and => can be omitted. In this case, only Value can be used
}
To be continued~
The above has introduced the PHP Caigou self-study path, including PHP and the content of the path. I hope it will be helpful to friends who are interested in PHP tutorials.