• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

php基本语法 - baraka

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

<?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 />";
}
?>


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
【php学习之路】php基础语法发布时间:2022-07-10
下一篇:
PHP 基本语法 - 陌上冬雪发布时间:2022-07-10
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap