demo1:
//Use two ways to output hello world and line break?>
demo2:
//Customize variable case and underline
//Define Boolean variables and output
$bo=true;
echo $bo.'
';
//Define integer variable and output
$bo=12;
echo $bo. '
';
//Define floating point variables and output
$bo=1.001;
echo $bo.'
';
// Define string variables and output them. Double quotes support escape characters, and single quotes support simple single quote escape.
$bo="oren word";
echo $bo.'
';
//Two ways to define arrays
$bo=array(1,2, 3,4);
//$bo=arrar("A"=>1,"B"=>2);
echo $bo[1];
?>
demo3:
//Introduction and application of PHP operation types.
//1. Arithmetic operation
echo 4+5*5/9;
//2. Assignment operation
$a=1;
echo $a.'
';
$a+=2;
echo $a.'
';
$a*=3;
echo $a.'
//3. Comparison operation, get Boolean value, true will output 1, false will output nothing.
//echo 1==2;
//echo 3!=2;
//echo 5<3;
//echo "ok"=="ok";
//The double equals sign only judges the numerical value; the triple equals sign will judge the type first, both the numerical value and the type.
echo (1=='1').'
';
//echo 1===='1';
//4. Logical operations.
echo (1&&1).'
';
echo (0&&1).'
';
echo (1||1).'
';
echo (0||1).'
';
//5. Increment and decrement operation
$b=1;
echo $b++." ";
echo ++$b."
?>
Copyright Statement: This article is an original article by the blogger and may not be reproduced without the blogger's permission.
The above introduces the basic syntax examples of PHP, including aspects of content. I hope it will be helpful to friends who are interested in PHP tutorials.