Forum und email

各類變數

Table of Contents

PHP 可以處理以下數據形態:

程式員通常不用指定變數是什麼形態。 PHP 會在運行根據該變數所含的值來自行決定該指派什麼類型給變數。

如果你想自己決定變數的形態或改變變數的形態, 要麼就是用變數套換, 不然就是調用 settype()函數。

必須注意不同形態的變數在特定情況下的不同表現。 這在 Type Juggling一節中有更詳細的描述。

整數

整數

$a = 1234; # decimal number
$a = -123; # a negative number
$a = 0123; # octal number (equivalent to 83 decimal)
$a = 0x12; # hexadecimal number (equivalent to 18 decimal)
The size of an integer is platform-dependent, although a maximum value of about 2 billion is the usual value (that's 32 bits signed).