php入門

來源:互聯網
上載者:User

標籤:int   php   字元   line   false   指令碼   資料類型   數字   資料類型轉換   

<?php echo"輸出字串";$intDate=print("php初學");//var_dump($intDate);$strDate1="2014年";$strDate2="2015年";echo $strDate1.$strDate2;//格式化輸出printf("%b",6);?>

  註:輸出字串

<?php//資料類型轉換//x轉換成boolean //數字轉布爾,非零都是true//字串轉布爾,非空都是true,除0字串外/* $intDate=12;$strDate="類型轉換";$boolDate=(boolean)$intDate;  var_dump($boolDate);   */      //x轉數字  //布爾轉數字true為1 false為0  //字串轉數字 空為0 非空,如果數字在我前為數字,否則為零/* $boolDate=true;$strDate="深網";$intDate=(integer)$boolDate;var_dump($intDate); *///x轉字串//布爾轉字串true為1 flase為空白串//數字轉字串非零為數字字串,0為0串$boolDate=false;$strDate=(string)$boolDate;var_dump($strDate);//判斷資料類型$intDate=8;if(is_bool($intDate)){echo"success";}else{echo"failed";}?>

  注釋:php中資料類型轉換

<?php //定義常量define("PHPCLASS",12);echo PHPCLASS;//檢測當前指令碼有沒有定義這個常量if(defined("PHPCLAS")){echo"有";}else{echo"沒有";}//預定義常量echo __FILE__;echo "<hr/>";echo __LINE__;echo "<hr/>";echo PHP_VERSION;echo "<hr/>";echo version_compare(PHP_VERSION,‘5.2.0‘);echo "<hr/>";echo PHP_OS;?>

  注釋:php中定義常量及預定義常量

php入門

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.