Code:
<! DOCTYPE html Public"-//w3c//dtd XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >PHP$a= 5;//define a variable line comment$b= 5;#single-line comment Echo"Hello World", "China";//multiple strings can be output at one time Echo"<br/>"; Print"Hello World";//only one string can be output Echo"<br/>"; //print_r ("AA");//Array $array=Array(1,2,3,4); Echo"<br/>"; Print_r($array); Echo"<br/>"; $str= "Hello";//variable Variable$hello= "Hello";$test= "Hello";echo $ $test;//Pay Attention to the wording Echo"<br/>";//isset ($hello) determine if a variable existsEcho isset($hello);//defined, output 1, not defined as null Echo"<br/>";//determine if the variable is empty$he="";Echo Empty($he);//empty words Output 1, non-empty output null Echo"<br/>";unset($hello);//Clear VariablesEcho $hello; Echo"<br/>";Echo isset($hello);//whether the query variable still exists Echo"<br/>";Var_dump ($STR);//data type of the output variable Echo"<br/>";//& get address, address change, change all $ss= "Helloo"; $str=&$ss; $str= "World"; Echo($ss); Echo"<br/>"; /*strongly typed languages: Strict 1, integer: int 2, float: float,double,decmial 3, character type: Char 4, String type: String 5, DateTime type: datetime 6, BOOL type 7, Odject int a= 5; Weakly typed language: Built-in language var a=5;*/? ><script language= "PHP" ></SCRIPT><?PHP$m= "123";$n = (int) $m;// type conversion (int)
//
/* Example:
$m = "1223";//String
$n = (int) $m;//Convert to Integer
Var_dump ($n);//output $n character type Huo echo GetType ($n);
echo $n;//Output $n */
Settype($m, int);//The second method goes directly, cannot be converted to a string by a variable, and the string is bound to the other.Echo is_string($m); Echo"<br/>";Var_dump($m); Echo"<br/>";//Mathematical Operators$h=10;$i=7;Echo $j=$h/$i;//% Echo"<br/>";Echo GetType($j);//in general, this method Echo"<br/>";Echo $h>$i?" H is greater than I ":" H is less than I "; Echo"<br/>";Echo true? " H is greater than I ":" H is less than I "; Echo"<br/>";Echo false?" H is greater than I ":" H is less than I "; Echo"<br/>";//stitching The string "." $hh= "Shuchu";$ii= "KJSNFK";Echo"$hh"."$ii"; Echo"<br/>";$x= "Han";$y= "Hui";$z= "Korean";$xx= "N001";$yy= "n002";$zz= "N003";$k="<select><option value= '$xx' >$x</option><option value= '$yy' >$y</option><option value= '$zz' >$z</option></select>";Echo $k;Echo"<br/>";Echo"Aaaaaa<br/>aaaa\taaaaa";?>
Huo
$a = "Han";
$b = "Hui";
$c = "Korean";
$AA = "n001";
$BB = "n002";
$CC = "n003";
$s = "<select>";
$s = $s. " <option value= ' ". $aa." > ". $a." </option> ";
$s = $s. " <option value= ' ". $bb." > ". $b." </option> ";
$s = $s. " <option value= ' ". $cc." > ". $c." </option> ";
$s = $s. " </select> ";
Echo $s;
</body>
Notes
PHP: A powerful scripting language
b/S program architecture: Brower: Browser Sever: Server
c/S program architecture: Client: Sever: Server
First, the markup of the PHP embedded page
1.<?php?>
2.<?> shop off Change to On
3.<script language= "PHP" ></script>
Second, PHP's comment syntax
1,//single-line comment
2. # single Comment
3,/* */multi-line Comment
Iii. output syntax for PHP
1. Echo "Hello World" and "China"; Multiple strings can be output at one time
2. Print "Hello World"//output only one string
3, Print_r ("AA");//Can output string numbers, you can output the array and the contents of the array
4, Var_dump (); Type of output variable
Iv. Types of data
PHP is a weakly typed language
Strongly typed languages: strict regulations
1, integral type: int
2. Float Type: float,double,decmial
3. Character type: Char
4. String Type: String
5, DateTime type: Date
6, BOOL Type
7, Odject type
int a=5;
Weakly typed languages:
Built-in languages
var a=5;
V. Definition of variables
Variables must start with $, variable names can be customized, but try not to use keywords
For example:
$STR = "AAA";
Variable variable:
$hello = "Hello";
$test = "Hello";
echo $ $test; ———— result is "hello", Output not ""
echo isset ($hello); Determines whether the defined variable exists to return 1, not to return an empty
echo unset ($hello); clear variable
echo Empty ($hello); Determines whether the variable is empty, empty string, and 0 are empty
Take the address, with the & symbol
Cases:
$ss = "Hello";
$str =& $ss;
$STR = "World";
Echo ($SS); ———— result for "world"
Take address, one change, all change
Vi. Conversion of data types
1. Get Type:
GetType ($m);
2. Determine if the data is of a certain kind
Is_ type name ($m);
3. Conversion type:
int ($m);
Example:
$m = "1223";//String
$n = (int) $m;//Convert to Integer
Var_dump ($n);//output $n character type
echo $n;//Output $n
Settype ($m, int);
Seven, operator expressions
1. Mathematical operators
/: Except integer results may be decimal (reason: PHP is weakly typed language)
2, String: Concatenation of strings with "."
3. Comparison operator = =
4. Logical operators
&&=and
|| =or
5. Error suppressor: @
6, three-bit operators:? :
7, \ t jump lattice
php--Beginner, Basic