(PECL spl_types >= 0.1.0)
SplString::__construct — Constructs a string object type
This constructs a new object of type string.
The input parameter accepts a string An UnexpectedValueException Exception will be thrown if anything else is passed.
没有返回值。
Example #1 SplString::__construct() example
<?php
$string = new SplString("Testing");
try {
$string = array();
} catch (UnexpectedValueException $uve) {
echo $uve->getMessage() . PHP_EOL;
}
var_dump($string);
echo $string; // Outputs "Testing"
?>
以上例程会输出:
Value not a string object(SplString)#1 (1) { ["__default"]=> string(7) "Testing" } Testing