久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      @PHP中的數(shù)據(jù)類型(1)

      PHP 支持八種原始類型。四種標(biāo)量類型:布爾型(boolean)整型(integer)浮點(diǎn)型(float)(浮點(diǎn)數(shù),也作“double”)字符串 (string)兩種復(fù)合類型:數(shù)組(array)對(duì)象(object)最后是兩種特殊類型:資源(resource)NULL為了確保代碼的易讀性,本 手冊(cè)還介紹了一些偽類型:混和(mixed)數(shù)字(number)回饋(callback)

      AD:

      PHP 支持八種原始類型。

      四種標(biāo)量類型:

      布爾型(boolean)

      整型(integer)

      浮點(diǎn)型(float)(浮點(diǎn)數(shù),也作“double”)

      字符串(string)

      兩種復(fù)合類型:

      數(shù)組(array)

      對(duì)象(object)

      最后是兩種特殊類型:

      資源(resource)

      NULL

      為了確保代碼的易讀性,本手冊(cè)還介紹了一些偽類型:

      混和(mixed)

      數(shù)字(number)

      回饋(callback)

      您可能還會(huì)讀到一些關(guān)于“雙精度(double)”類型的參考。實(shí)際上 double 和 float 是相同的,由于一些歷史的原因,這兩個(gè)名稱同時(shí)存在。

      變量的類型通常不是由程序員設(shè)定的,確切地說,是由 PHP 根據(jù)該變量使用的上下文在運(yùn)行時(shí)決定的。

      注: 如果你想查看某個(gè)表達(dá)式的值和類型,用 var_dump()。

      注: 如果你只是想得到一個(gè)易讀懂的類型的表達(dá)方式用于調(diào)試,用 gettype()。要查看某個(gè)類型,不要用 gettype(),而用 is_type 函數(shù)。以下是一些范例:

      <?php $bool = TRUE;  // a boolean $str  = "foo";  // a string $int  = 12;    // an integer  echo gettype($bool); // prints out "boolean" echo gettype($str);  // prints out "string"  // If this is an integer, increment it by four if (is_int($int)) {    $int += 4; }  // If $bool is a string, print it out // (does not print out anything) if (is_string($bool)) {    echo "String: $bool"; } ?>   

      如果你要將一個(gè)變量強(qiáng)制轉(zhuǎn)換為某類型,可以對(duì)其使用強(qiáng)制轉(zhuǎn)換或者 settype() 函數(shù)。

      注意變量根據(jù)其當(dāng)時(shí)的類型在特定場(chǎng)合下會(huì)表現(xiàn)出不同的值。更多信息見類型戲法。此外,你還可以參考 PHP 類型比較表看不同類型相互比較的例子。

       布爾型

      這是最簡單的類型。boolean 表達(dá)了真值,可以為 TRUE 或 FALSE。

      注: 布爾類型是 PHP 4 引進(jìn)的。

      語法

      要指定一個(gè)布爾值,使用關(guān)鍵字 TRUE 或 FALSE。兩個(gè)都是大小寫不敏感的。

      <?php $foo = True; // assign the value TRUE to $foo ?> 

      通常你用某些運(yùn)算符返回 boolean 值,并將其傳遞給流程控制。

      // == is an operator which test // equality and returns a boolean if ($action == "show_version") {    echo "The version is 1.23"; }  // this is not necessary... if ($show_separators == TRUE) {    echo "                                 

                                       n"; }  // ...because you can simply type if ($show_separators) {    echo "                                 

                                       n"; }  

      轉(zhuǎn)換為布爾值

      要明示地將一個(gè)值轉(zhuǎn)換成 boolean,用 (bool) 或者 (boolean) 來強(qiáng)制轉(zhuǎn)換。但是很多情況下不需要用強(qiáng)制轉(zhuǎn)換,因?yàn)楫?dāng)運(yùn)算符,函數(shù)或者流程控制需要一個(gè) boolean 參數(shù)時(shí),該值會(huì)被自動(dòng)轉(zhuǎn)換。

      參見類型戲法。

      當(dāng)轉(zhuǎn)換為 boolean 時(shí),以下值被認(rèn)為是 FALSE:

      布爾值 FALSE

      整型值 0(零)

      浮點(diǎn)型值 0.0(零)

      空白字符串和字符串 “0”

      沒有成員變量的數(shù)組

      沒有單元的對(duì)象

      特殊類型NULL(包括尚未設(shè)定的變量)

      所有其它值都被認(rèn)為是 TRUE(包括任何資源)。

      <?php echo gettype((bool) "");        // bool(false) echo gettype((bool) 1);        // bool(true) echo gettype((bool) -2);        // bool(true) echo gettype((bool) "foo");    // bool(true) echo gettype((bool) 2.3e5);    // bool(true) echo gettype((bool) array(12)); // bool(true) echo gettype((bool) array());  // bool(false) ?>  


      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)