note 129691 added to stringable.tostring
| From: | zikro32@gmail.com | Date: | Wed, 07 Aug 2024 11:42:53 +0000 |
| Subject: | note 129691 added to stringable.tostring | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-221463@lists.php.net to get a copy of this message | ||
__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.
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.137 (proxied: 87.202.174.143)
----
Manual Page -- https://php.net/manual/en/stringable.tostring.php
Edit -- https://main.php.net/note/edit/129691
Del: integrated -- https://main.php.net/note/delete/129691/integrated
Del: useless -- https://main.php.net/note/delete/129691/useless
Del: bad code -- https://main.php.net/note/delete/129691/bad+code
Del: spam -- https://main.php.net/note/delete/129691/spam
Del: non-english -- https://main.php.net/note/delete/129691/non-english
Del: in docs -- https://main.php.net/note/delete/129691/in+docs
Del: other reasons-- https://main.php.net/note/delete/129691
Reject -- https://main.php.net/note/reject/129691
Search -- https://main.php.net/manage/user-notes.php