PHP Doku:: Constructs an integer object type - splint.construct.html

Verlauf / Chronik / History: (4) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzSonstige GrunderweiterungenSPL Type HandlingThe SplInt classSplInt::__construct

Ein Service von Reinhard Neidl - Webprogrammierung.

The SplInt class

<<The SplInt class

The SplFloat class>>

SplInt::__construct

(PECL spl_types >= 0.1.0)

SplInt::__constructConstructs an integer object type

Beschreibung

SplInt::__construct() ( integer $input )

This constructs a new object of type integer.

Parameter-Liste

input

The input parameter accepts an integer An UnexpectedValueException Exception will be thrown if anything is passed.

Rückgabewerte

Es wird kein Wert zurückgegeben.

Beispiele

Beispiel #1 SplInt::__construct() example

<?php
$int 
= new SplInt(94);

try {
    
$int 'Try to cast a string value for fun';
} catch (
UnexpectedValueException $uve) {
    echo 
$uve->getMessage() . PHP_EOL;
}

var_dump($int);
echo 
$int// Outputs 94
?>

Das oben gezeigte Beispiel erzeugt folgende Ausgabe:

Value not an integer
object(SplInt)#1 (1) {
  ["__default"]=>
  int(94)
}
94


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",...)