PHP 语法基础(-)

$a="word";

echo strlen($a);

echo strpos($a,"word");

define("NAME","MIA",true);

define("NAME","MIA",false);

echo NAME;

$a1=2;$a2=3;$a1++;

echo($a1);

$txt1="hello"; $txt2="world!";$txt2=$txt1."world";$txt1.=$txt2;

echo($txt1);

echo"$txt1,$txt2";

$x=100;$y="100";

var_dump($x==$y);

var_dump($x===$y);

 $ar=array("a","b");

 $ar2=array("c","d");

$ar4=$ar + $ar2;

var_dump($ar4);

$t=date("H");

if($t>"20")

{echo "have a good day!";}

else{  echo"have a good night!";}

$x=3;

switch($x)

{    case 1:   

 echo"number 1";   

 break;   

 case 2:  

 echo"number 2"; 

 break;   

 default:   

 echo"number between";

  break;

};

 while($x<6)

 echo"这是一个可以的数:$x"; 

 $x++;

}


$num=false; 

do{ 

 $x++;  

 echo "this is $x";  

 if($x>10)

 $num=true;

}

}while($num==false);


for($i=0;$i<10;$i++)

{

echo"this is number$i\n";

}


foreach($ar as $value)

{

echo"this value is $value\n";

}

你可能感兴趣的:(PHP 语法基础(-))