PHP 8.6.0 Beta 1 is available for testing

SplFixedArray::__construct

(PHP 5 >= 5.3.0, PHP 7, PHP 8)

SplFixedArray::__constructConstruye un nuevo SplFixedArray

Descripción

public function SplFixedArray::__construct(int $size = 0)

Inicializa un array fijo con un número de valores null iguales al argumento size.

Parámetros

size

El tamaño del array de tamaño fijo. Espera un número comprendido entre 0 y PHP_INT_MAX .

Errores/Excepciones

Lanza una excepción ValueError cuando size es negativo.

Historial de cambios

Versión Descripción
8.0.0 Ahora lanza una excepción ValueError cuando size es negativo. Anteriormente, se lanzaba una InvalidArgumentException .

Ejemplos

Ejemplo #1 Ejemplo con SplFixedArray::__construct()

<?php
$array = new SplFixedArray(5);
$array[1] = 2;
$array[4] = "foo";
foreach($array as $v) {
 var_dump($v);
}
?>

El ejemplo anterior mostrará:

NULL
int(2)
NULL
NULL
string(3) "foo"

Found A Problem?

Learn How To Improve This PageSubmit a Pull RequestReport a Bug
+add a note

User Contributed Notes

There are no user contributed notes for this page.

AltStyle によって変換されたページ (->オリジナル) /