<?php
echo "hello test01";
$var ="PHP";
echo "$var";
echo "<br />";
$var ="JAVA";
echo "$var";
echo "<br />";
$a ="苹果";
$b =10;
var_dump($a);
var_dump($b);
echo "<br />";
$m ="m";
$M ="M";
echo "$m";
echo "$M";
echo "<br />";
echo $m1=memory_get_usage();
echo "<br />";
$v1="123";
echo $m2=memory_get_usage()-$m1;
echo "<br />";
$v2=123;
echo $m3=memory_get_usage()-$m1-$m2;
echo "<br />";
$v3=123.00;
echo $m4=memory_get_usage()-$m1-$m2-$m3;
echo "<br />";
$v4=array("123");
echo $m5=memory_get_usage()-$m1-$m2-$m3-$m4;
echo "<br />";
$string="就是就是";
var_dump($string);
echo "<br />";
$string=9494;
var_dump($string);
echo "<br />";
$man ="男";
$flag=$man=="男";
echo $flag;
echo "<br />";
var_dump($flag);
echo "<br />";
$data_int1=123;
echo $data_int1;
echo "<br />";
$data_int2=-123;
echo $data_int2;
echo "<br />";
$data_int3=0123;
echo $data_int3;
echo "<br />";
$data_int4=0x123;
echo $data_int4;
echo "<br />";
$num_float1=1.234;
echo $num_float1;
echo "<br />";
$num_float2=1.2e3;
echo $num_float2;
echo "<br />";
$num_float3=7.0E-3;
echo $num_float3;
echo "<br />";
$str_string1=\'我是字符串\';
$str_string2="我也是字符串";
echo $str_string1;
echo "<br />";
echo $str_string2;
echo "<br />";
$file_handle=fopen("1.txt","r");
if($file_handle){
while(!feof($file_handle)){
$line=fgets($file_handle);
echo $line;
echo "<br />";
}
}
fclose($file_handle);
echo "<br />";
error_reporting(0);
$var;
var_dump($var);
echo "<br />";
$var1=null;
var_dump($var1);
echo "<br />";
$var2=NULL;
var_dump($var2);
echo "<br />";
$var3="生日快乐";
unset($var3);
var_dump($var3);
echo "<br />";
$p="PII";
define("PI",3.14);
define($p,3.14);
echo PI;
echo "<br />";
echo PII;
echo "<br />";
$r=3;
echo "mianji:".(PI*$r*$r)."<br />";
echo "zhouchang:".(2*PI*$r)."<br />";
echo "<br />";
echo _FILE_;
echo "<br />";
echo _LINE_;
echo "<br />";
echo PHP_VERSION;
echo "<br />";
echo PHP_OS;
echo "<br />";
$p="";
define("PI1",3.14);
define("PI2",3.142);
$height="M";
if($height=="M"){
$p="PI1";
}else if($height=="T"){
$p="PI2";
}
$r=2;
$area=constant($p)*$r*$r;
echo $area;
echo "<br />";
$is1=defined($p);
$is2=defined("PI3");
var_dump($is1);
var_dump($is2);
echo "<br />";
$a=1;$b=2;
$c=$a+$b;
echo $c;
echo "<br />";
$a=1;
$b="1";
var_dump($a==$b);
echo "<br />";
var_dump($a===$b);
echo "<br />";
var_dump($a!=$b);
echo "<br />";
var_dump($a!==$b);
echo "<br />";
$a=78;
$b=$a>=60?"yes":"no";
echo $b;
echo "<br />";
$a=TRUE;
$b=TRUE;
$c=FALSE;
$d=FALSE;
echo ($a and $b)?"y":"n";
echo "<br />";
echo ($a or $b)?"y":"n";
echo "<br />";
echo ($a xor $c xor $d)?"y":"n";
echo "<br />";
echo !$c?"y":"n";
echo "<br />";
echo $a && $d ?"y":"n";
echo "<br />";
echo $a || $c || $d ?"y":"n";
echo "<br />";
$conn =@mysql_connect("localhost","username","password");
echo "error,the reason:".$php_errormsg;
echo "<br />";
$sex="男";
if($sex=="男"){
echo "yes";
}else if($sex=="女"){
echo "no";
}
echo "<br />";
$num=rand(1,5);
$info="";
switch($num){
case 1:
$info="1";
break;
case 2:
$info="2";
break;
case 3:
$info="3";
break;
default:
$info="no";
}
echo $info;
echo "<br />";
echo "<br />";
$sum=12;
echo "hungry";
echo "<br />";
while($sum<100){
$num=rand(1,20);
$sum=$sum+$num;
if($sum<100){
echo "not";
echo "<br />";
}
}
echo $sum;
echo "<br />";
$students =array(
\'2001\'=>\'A\',
\'2002\'=>\'B\',
\'2003\'=>\'C\',
\'2004\'=>\'D\',
\'2005\'=>\'E\',
);
foreach($students as $student){
echo $student;
echo "<br />";
}
echo "<br />";
$grades =array(
\'2011\'=>array(\'A\',"33"),
\'2012\'=>array(\'B\',"44"),
\'2013\'=>array(\'C\',"55"),
\'2014\'=>array(\'D\',"66"),
\'2015\'=>array(\'E\',"77"),
);
foreach($grades as $key=>$val){
echo $key;
echo ":";
foreach($val as $v){
echo $v;
}
echo "<br />";
}
?>