PHP Doku:: Constructs a string object type - splstring.construct.html

Verlauf / Chronik / History: (5) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzSonstige GrunderweiterungenSPL Type HandlingThe SplString classSplString::__construct

Ein Service von Reinhard Neidl - Webprogrammierung.

The SplString class

<<The SplString class

Streams>>

SplString::__construct

(PECL spl_types >= 0.1.0)

SplString::__constructConstructs a string object type

Beschreibung

SplString::__construct() ( string $input )

This constructs a new object of type string.

Parameter-Liste

input

The input parameter accepts a string An UnexpectedValueException Exception will be thrown if anything else is passed.

Rückgabewerte

Es wird kein Wert zurückgegeben.

Beispiele

Beispiel #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"
?>

Das oben gezeigte Beispiel erzeugt folgende Ausgabe:

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


Keine BenutzerBeiträge.
- Beiträge aktualisieren...



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)