- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml"xml:lang="zh-cn">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>站长下载|中国最大的站长资源站</title>
- <!--meta http-equiv="Content-Language" content="zh-cn">
- <meta http-equiv="Content-Type" content="text/html; charset=gb2312"-->
- <meta name="keyworlds" content="关键字列表"/ >
- <link rel="stylesheet" type="text/css" href=""/>
- <style type="text/css"></style>
- <script type="text/javascript"></script>
- </head>
- </body>
- <?php
- //定义形式1
- define("PI", 3.1415926);
- define("SCHOOL", "传智播客");
- define("CC1", 1234);
- define("CC2", "abcd");
- //定义形式2
- //const CC1 = 1234;
- //const CC2 = 'abcd';
- //使用形式1
- echo "<br/>常量PI的值是:".PI;
- echo "<br/>常量SCHOOL的值是:".SCHOOL;
- $s1 = PI*3*3;
- //使用形式2:使用函数constant()获得常量的值
- $s2 = constant("PI")*3*3;
- echo "<br/>s1=$s1,s2=$s2";
- echo "<br/>".SCHOOL.constant("CC1").constant("CC2");
- //取得常量值的灵活语法//常量的名字也可以拼凑
- $i=1;
- $c1="CC".$i;
- echo "<br/>常量$c1的值为:".constant($c1);
- echo "<br/>";
- //判断常量是否存着
- if(defined("PI")){
- echo"PI is cunzai";//常量存着
- }else{
- echo "PI is bucunzai";
- define("PI",3.1415926);//常量不存在创建常量
- }
- $s3=PI*5*5;
- echo "<br/>mianji=$s3";
- echo "<br/>";
- if(defined("G")){
- echo"G is cunzai";//常量G存着
- }else{
- echo "G is bucunzai";
- define("G",9.8);//常量G不存在创建常量
- }
- $s4=G*5;//G为重力加速度
- echo "<br/>shudu:$s4";
- echo "<br/>";
- echo "v2 de zhi wei".$v2;
- echo "<br/>";
- echo "C1 de zhi wei".C1;
- echo "<br/>";
- echo CC1;
- echo "<br/>";
- //预定义常量
- echo M_PI;
- echo "<br/>";
- echo PHP_os;
- echo "<br/>";
- echo PHP_VERSION;
- echo "<br/>";
- //魔术常量
- echo "<br/>".__FILE__;//当前网页文件的完整物理路径
- echo "<br/>". __DIR__;
- echo "<br/>".__LINE__;//当前常量所在的行号
- echo "<br/>".__LINE__;
- ?>
- <?php
- $n1=123;
- $s1=decbin($n1);
- $s2=decoct($n1);
- $s3=dechex($n1);
- echo "<br/>$s1";
- echo "<br/>$s2";
- echo "<br/>$s3";
- $n4=0123;
- $n5="0123";
- $n6="123";
- $n7=0x12;//其实就是$n7=18;or $n7="18";or $n7="0x18";
- $n8="0x12";
- $n9="12";
- $n10=12;
- $s7=hexdec($n7);
- $s8=hexdec($n8);
- $s9=hexdec($n9);
- $s10=hexdec($n10);
- echo "<br/>$s7";//24
- echo "<br/>$s8";//18
- echo "<br/>$s9";//18
- echo "<br/>$s10";//18
- $s11=dechex($n7);
- echo "<br/>$s11";//12
- echo "<br/>$n4,<br/>$n7";//83,18
- echo "<br/>php的输出结果是:".(8.1/3);
- ?>
- <script>
- document.write("<br/>js的输出结果是:"+(8.1/3));
- </script>
- <?php
- echo "<br/>";
- if(!empty($_POST)){
- $d1=$_POST['data1'];
- $d2=$_POST['data2'];
- $n1=$_POST['num1'];
- $n2=$_POST['num2'];
- $n3=$_POST['yunsuanfu'];
- echo "d1=$d1,d2=$d2,n1=$n1,n3=$n3,n2=$n2";
- If($n3=="+"){$jieguo=$n1 + $n2;
- }else if ($n3=="-"){
- $jieguo=$n1 - $n2;
- }else if ($n3=="*"){
- $jieguo=$n1 * $n2;
- }else if ($n3=="/"){
- $jieguo=$n1 / $n2;
- }
- echo"jieguo=$jieguo,<hr/r>";
- print_r($_POST);
- }else{echo"非法的页面访问";
- $jieguo="";
- $n1="";
- $n2="";
- }
- ?>
复制代码 |
|