SplObjectStorage::current

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

SplObjectStorage::currentReturns the current storage entry

Beschreibung

public SplObjectStorage::current(): object

Returns the current storage entry.

Parameter-Liste

Diese Funktion besitzt keine Parameter.

Rückgabewerte

The object at the current iterator position.

Changelog

Version Beschreibung
8.1.0 SplObjectStorage::current() now throws an Error exception if the current position is invalid. Previously, false was returned instead.

Beispiele

Beispiel #1 SplObjectStorage::current() example

<?php
$s 
= new SplObjectStorage();

$o1 = new StdClass;
$o2 = new StdClass;

$s->attach($o1"d1");
$s->attach($o2"d2");

$s->rewind();
while(
$s->valid()) {
    
$index  $s->key();
    
$object $s->current(); // similar to current($s)
    
$data   $s->getInfo();

    
var_dump($object);
    
var_dump($data);
    
$s->next();
}
?>

Das oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:

object(stdClass)#2 (0) {
}
string(2) "d1"
object(stdClass)#3 (0) {
}
string(2) "d2"

Siehe auch

Hier Kannst Du einen Kommentar verfassen


Bitte gib mindestens 10 Zeichen ein.
Wird geladen... Bitte warte.
* Pflichtangabe
Es sind noch keine Kommentare vorhanden.

Was genau bedeutet "Vibe Coding"? Ein tiefgehender Blick für Entwickler

In der Welt der Softwareentwicklung gibt es unzählige Wege, wie man an ein Projekt herangeht. Manche schwören auf strikte Planung, andere auf bewährte Algorithmen und wieder andere lassen sich von etwas ganz anderem leiten: ihrem Gefühl. ...

admin

Autor : admin
Kategorie: Software & Web-Development

PHP cURL-Tutorial: Verwendung von cURL zum Durchführen von HTTP-Anfragen

cURL ist eine leistungsstarke PHP-Erweiterung, die es Ihnen ermöglicht, mit verschiedenen Servern über verschiedene Protokolle wie HTTP, HTTPS, FTP und mehr zu kommunizieren. ...

TheMax

Autor : TheMax
Kategorie: PHP-Tutorials

Midjourney Tutorial - Anleitung für Anfänger

Über Midjourney, dem Tool zur Erstellung digitaler Bilder mithilfe von künstlicher Intelligenz, gibt es ein informatives Video mit dem Titel "Midjourney Tutorial auf Deutsch - Anleitung für Anfänger" ...

Mike94

Autor : Mike94
Kategorie: KI Tutorials

Tutorial veröffentlichen

Tutorial veröffentlichen

Teile Dein Wissen mit anderen Entwicklern weltweit

Du bist Profi in deinem Bereich und möchtest dein Wissen teilen, dann melde dich jetzt an und teile es mit unserer PHP-Community

mehr erfahren

Tutorial veröffentlichen

Bild drehen

Nice tips! It's great to see developers actively helping each other with real-world PHP challenges like this. If you're as curious as I am about s ...

Geschrieben von rahulhsol am 04.06.2025 11:11:21
Forum: PHP Developer Forum
Bild drehen

Glad I found this post. I’ve been searching for a reliable way to auto-rotate uploaded images correctly. If you're as curious as I am about solu ...

Geschrieben von rahulhsol am 04.06.2025 11:09:45
Forum: PHP Developer Forum
Bild drehen

Good discussion! I’ve used similar functions in my projects, but this thread gave me a fresh perspective. If you're as curious as I am about sol ...

Geschrieben von rahulhsol am 04.06.2025 11:04:01
Forum: PHP Developer Forum
Bild drehen

I appreciate the clear explanation. Rotating images with PHP gets confusing sometimes—this helps simplify it. If you're as curious as I am about ...

Geschrieben von rahulhsol am 04.06.2025 11:02:09
Forum: PHP Developer Forum