最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

PHP 類型轉(zhuǎn)換函數(shù)intval

 更新時間:2009年06月20日 00:14:53   作者:  
不管什么類型 如果是數(shù)字,就返回數(shù)字,如果不是數(shù)字就返回0 在PHP中用$_GET['id']的時候就可以這樣來一個轉(zhuǎn)換...太好了
PHP代碼
$id = intval($_GET['id']);
intval
(PHP 4, PHP 5)
intval — Get the integer value of a variable
Description
int intval ( mixed $var [, int $base= 10 ] )
Returns the integer value of var , using the specified base for the conversion (the default is base 10).
Parameters
var
The scalar value being converted to an integer
base
The base for the conversion (default is base 10)
Return Values
The integer value of var on success, or 0 on failure. Empty arrays and objects return 0, non-empty arrays and objects return 1.
The maximum value depends on the system. 32 bit systems have a maximum signed integer range of -2147483648 to 2147483647. So for example on such a system, intval('1000000000000') will return 2147483647. The maximum signed integer value for 64 bit systems is 9223372036854775807.
Strings will most likely return 0 although this depends on the leftmost characters of the string. The common rules of integer casting apply.
Examples
復制代碼 代碼如下:

<?php
echo intval(42); // 42
echo intval(4.2); // 4
echo intval('42'); // 42
echo intval('+42'); // 42
echo intval('-42'); // -42
echo intval(042); // 34
echo intval('042'); // 42
echo intval(1e10); // 1410065408
echo intval('1e10'); // 1
echo intval(0x1A); // 26
echo intval(42000000); // 42000000
echo intval(420000000000000000000); // 0
echo intval('420000000000000000000'); // 2147483647
echo intval(42, 8); // 42
echo intval('42', 8); // 34
?>

相關(guān)文章

  • PHP讀取大文件末尾N行的高效方法推薦

    PHP讀取大文件末尾N行的高效方法推薦

    下面小編就為大家?guī)硪黄狿HP讀取大文件末尾N行的高效方法推薦。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2016-06-06
  • php模擬服務器實現(xiàn)autoindex效果的方法

    php模擬服務器實現(xiàn)autoindex效果的方法

    這篇文章主要介紹了php模擬服務器實現(xiàn)autoindex效果的方法,實例分析了php操作URL及傳遞參數(shù)的技巧,具有一定參考借鑒價值,需要的朋友可以參考下
    2015-03-03
  • 淺析PHP中json_encode與json_decode的區(qū)別

    淺析PHP中json_encode與json_decode的區(qū)別

    這篇文章主要介紹了淺析PHP中json_encode與json_decode的區(qū)別,PHP提供json_encode()和json_decode()函數(shù),前者用于編碼,后者用于解碼。下面來分析下這兩個函數(shù),感興趣的可以了解一下
    2020-07-07
  • PHPExcel導出2003和2007的excel文檔功能示例

    PHPExcel導出2003和2007的excel文檔功能示例

    這篇文章主要介紹了PHPExcel導出2003和2007的excel文檔功能,結(jié)合實例形式分析了PHPExcel屬性設(shè)置及文檔導出操作相關(guān)技巧,需要的朋友可以參考下
    2017-01-01
  • PHP也能干大事之PHP中的編碼解碼詳解

    PHP也能干大事之PHP中的編碼解碼詳解

    這篇文章主要介紹了PHP也能干大事之PHP中的編碼解碼詳解,本文講解了ASCII編解碼、URL編解碼、Base64編解碼、HTML實體編解碼、二進制、八進制、十進制、十六進制相互轉(zhuǎn)換等內(nèi)容,需要的朋友可以參考下
    2015-04-04
  • PHP實現(xiàn)將顏色hex值轉(zhuǎn)換成rgb的方法

    PHP實現(xiàn)將顏色hex值轉(zhuǎn)換成rgb的方法

    這篇文章主要介紹了PHP實現(xiàn)將顏色hex值轉(zhuǎn)換成rgb的方法,涉及PHP針對字符串與數(shù)組的數(shù)學運算相關(guān)操作技巧,需要的朋友可以參考下
    2016-05-05
  • 100行PHP代碼實現(xiàn)socks5代理服務器

    100行PHP代碼實現(xiàn)socks5代理服務器

    這個例子說了in the real world, do something here to ensure clients not running are destroyed 但是,如何把不再運行的連接銷毀卻沒有講。恩。我試了把$clients放到一個類里,把類傳給線程類,然后在線程類要結(jié)束時把$clients里對應的連接給unset掉,無果。
    2016-04-04
  • PHP實現(xiàn)文件上傳和多文件上傳

    PHP實現(xiàn)文件上傳和多文件上傳

    這篇文章主要介紹了PHP實現(xiàn)文件上傳和多文件上傳的相關(guān)資料,還為大家分享了解決如何修改PHP上傳文件的大小限制問題的方法,需要的朋友可以參考下
    2015-12-12
  • PHP 函數(shù)語法介紹一

    PHP 函數(shù)語法介紹一

    PHP的上漲支持一流的職能和關(guān)閉。真正的無名氏功能支持使用下面的語法
    2009-06-06
  • php上傳大文件失敗的原因及應對策略

    php上傳大文件失敗的原因及應對策略

    這篇文章主要介紹了php上傳大文件失敗的原因及應對策略的相關(guān)資料,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2015-10-10

最新評論

双城市| 会同县| 彰化市| 桃源县| 阿瓦提县| 晋城| 佛山市| 罗江县| 忻州市| 玛曲县| 阿荣旗| 邹城市| 洱源县| 什邡市| 泰来县| 信丰县| 化州市| 淳安县| 松江区| 盐源县| 蚌埠市| 吴桥县| 安宁市| 安康市| 云林县| 墨脱县| 曲沃县| 郧西县| 浦北县| 潞西市| 台前县| 临武县| 汝城县| 湖口县| 遂川县| 金堂县| 长沙县| 长春市| 英超| 曲水县| 竹溪县|