<?php
$a = 6;
echo $a; //注释语法
/* 多行注释 */ //输出语法
echo "hello";
echo "world","dhakj"; //可以输出多个字符串 print "aaa"; //只能输出一个字符串 print_r(); //打印数组
var_dump(); //输出变量及类型 //变量定义
//数据类型,弱类型语言
$a = "hello";
$hello = "world"; echo $$a; //可变变量 //类型转换
$a = 6;
$b = (string)$a; //类型转换
settype($a,"string"); //另外方式
var_dump($a); //运算符与表达式
$a = 6;
$b = 7; $c = $a == $b;
var_dump($c); $a = "hello";
$b = "world";
$c = $a.$b; //拼接字符串用的是点(.)
echo $c; $a = 8;
@$c = $a/$b; //错误抑制符
echo $c; //php里面的错误信息
//Notice:提醒
//warning:警告
//error:错误 //三元运算符
$a = 4;
$b = 5;
echo $a==$b?"相等":"不相等"; //语句
//顺序
$a = 5;
$b = 6;
//分支
if($a==$b)
{
echo "相等";
}
else
{
echo "不相等";
} switch($a)
{
case 4:
echo "4444";
break;
case 5:
echo "55555";
break;
case 6:
echo "66667";
break;
default:
echo "000000";
} //循环
for($a=0;$a<10;$a++)
{
echo $a;
} while(true)
{
echo "aaa";
} do
{ }
while() ?>