Php/docs/class.splstring

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

(PECL spl_types >= 0.1.0)

はじめに

SplString クラスは、文字列型をより強力に型付けするために使用します。


クラス概要


SplString extends SplType {

/* 定数 */

const string __default =

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

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

}

定義済み定数

SplString::__default


例1 SplString の使用例

<?php$string = new SplString("Testing");try {    $string = array();} catch (UnexpectedValueException $uve) {    echo $uve->getMessage() . PHP_EOL;}var_dump($string);echo $string; // 出力は "Testing"?>

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


Value not a string
object(SplString)#1 (1) {
  ["__default"]=>
  string(7) "Testing"
}
Testing