php常用函數整理

來源:互聯網
上載者:User

標籤:平方根   php常用函數   ring   類型   數組   span   color   bsp   div   

1.類型轉換

php基本類型有 int,float,string,bool,array,object,轉換方式有三種,這裡只介紹下面一種

(int)  (bool)  (float)  (string)  (array) (object)

 $i = 1;                 //int 1     $i = (bool)$i;       //boolean true   $i = (string)$i;     //string ‘1‘    $i = (double)$i;   //string ‘1‘   $i = (array)$i;     //array(size=1) 0=>1 $i = (object)$i;   //object(stdClass)[1] public 0=>1    

除了以上 還有strval(),intval(),floatval(),settype()等方式 

Note:不要把未知分數轉換為int類型,這是一個坑.

2.數學函數
$i = -7.8;$a = abs($i);   //絕對值 7.8$a = ceil($i);  //向上取整 -7$a = floor($i); //向下取增 -8$a = round($i); //四捨五入 -8$a = sqrt(9);  //開平方根 3$a = pow(3,3); //次方運算 27$a = rand(1,100);  //自動化佈建隨機數 擷取1到100範圍內的數字$a = log(8,2); //對數運算,第二個參數為底 3$a =max(1,2,3,4,5); //設定任意個參數 求最大 5$a =max([1,2,3,4,5]); //傳入數組求最大 5//min函數同上

 

3.字串函數

 

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.