php基礎之數據類型(一)

<?php
 //設置請求消息頭,避免亂碼狀況
  header("Content-type:text/html;charset=GBK");
  
 echo 'Hello Wecome To PHP World';
 
 echo '<br>';
 /* 變量的聲明  */
 
 $r4=true;
 $r5=false;
 if ($r4!=false){
 	echo '$r4爲FALSE';
 	echo '<br>';
 }elseif ($r5==true){
 	echo '$r5爲true';
 	echo '<br>';
 }else {
 	echo "$r4"."$r5";
 	echo '<br>';
 }
 /*====界定符=====*/
 $s1 ='I LOVE PHP';
  $s2= str_split($s1,3);//將string截取爲數組
 echo <<<s
   $s1 
   $s2[1]
   
s;
  
 $str =true;
 $i=1;
  if ($str){
  //字符串轉化爲int類型時,開頭是數字自動截取到非數字部分,不然爲0;	
  	$i++;
  	echo '4s'+$i;// 6
  	echo '<br>';
  	echo 'e3'+$i;//2
  	
  }
  /*  =====整型變量===== 
   * 超出integer類型的範圍自動轉化爲float處理
   *  */
  $int1 = 1234;
  $int2 =0777777777777777777777777777777777777;
  $int3 = 0x1f;
  echo '$int1 十進制的結果是:'.$int1.'<br>';
  echo '$int2 的十進制結果是:'.$int2.'<br>';//3.24518553658E+32
  
  echo '$int3 的十進制是:'.$int3.'<br>';
  //圓周率的寫法
  echo '圓周率的寫法:'.pi().'<br>';
  //echo 314543245='.3.1415926531.'<br>';
  
  
  /*特殊數據類型的處理
   * resource和null
   * */
  $t1 =null;
  $t2;//未初始化爲null
  $t3="good";
  if (is_null($t1)){
  	echo '$t1爲null值'.'<br>';
  }
  if (is_null($t2)){
  	echo '未賦值變量爲null'.'<br>';
  }
  //未聲明爲null
  if (is_null($t6)){
  	
  	echo '未聲明變量爲null'.'<br>';
  	
  }
  
  echo 'unset 前$t3的值'.'<br>';
  if (!is_null($t3)){
  	echo '<a style="color:cyan;">$t3不爲null值</a>'.'<br>';
  }
  //將指定的變量銷燬
  unset($t3);
  echo '<span style="color:red;">指定變量銷燬後的值</span>'.'<br>';
  if (is_null($t3)){
  	echo '$t3爲null值'.'<br>';
  }
  
 

?>
相關文章
相關標籤/搜索