Php/docs/class.splint

提供:Dev Guides
< Php
移動先:案内検索

(PECL spl_types >= 0.1.0)

はじめに

SplInt クラスは integer 型をより強力に型付けするために使用します。


クラス概要


SplInt extends SplType {

/* 定数 */

const int __default = 0

/* 継承したメソッド */

SplType::__construct ([ mixed $initial_value [, bool $strict ]] )

}

定義済み定数

SplInt::__default


例1 SplInt の使用例

<?php$int = new SplInt(94);try {    $int = '試しに文字列をキャストしてみましょう';} catch (UnexpectedValueException $uve) {    echo $uve->getMessage() . PHP_EOL;}echo $int . PHP_EOL;?>

上の例の出力は以下となります。


Value not an integer
94