Stringable::__toString

(PHP 8)

Stringable::__toString — Retourne la représentation de l'objet sous forme de chaîne

Description

public function Stringable::__toString(): string

Liste de paramètres

Cette fonction ne contient aucun paramètre.

Valeurs de retour

Retourne la représentation d'un objet sous la forme d'une chaîne de caractères.

Voir aussi

Found A Problem?

Learn How To Improve This Page • Submit a Pull Request • Report a Bug
+add a note

User Contributed Notes 1 note

up
3
zikro32 at gmail dot com
2 years ago
__toString() magic method is not intended to be called directly.
Instead, it defines what is returned when the object is cast to string, either explicitly casting with:
(string)$element
Or implicitly, when used in certain contexts which would cause a conversion to string.
If you really want to explicitly call a method to convert an object to string, then you can just create a public toString method and call that, avoid using the magic __toString directly if no casting is needed.
+add a note

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