The __toString() method is extremely useful for converting class attribute names and values into common string representations of data (of which there are many choices). I mention this as previous references to __toString() refer only to debugging uses.
I have previously used the __toString() method in the following ways:
- representing a data-holding object as:
- XML
- raw POST data
- a GET query string
- header name:value pairs
- representing a custom mail object as an actual email (headers then body, all correctly represented)
When creating a class, consider what possible standard string representations are available and, of those, which would be the most relevant with respect to the purpose of the class.
Being able to represent data-holding objects in standardised string forms makes it much easier for your internal representations of data to be shared in an interoperable way with other applications.
----
Server IP: 92.48.74.199
Probable Submitter: 62.56.124.226
----
Manual Page -- http://www.php.net/manual/en/language.oop5.magic.php
Edit -- https://master.php.net/note/edit/86111
Del: integrated -- https://master.php.net/note/delete/86111/integrated
Del: useless -- https://master.php.net/note/delete/86111/useless
Del: bad code -- https://master.php.net/note/delete/86111/bad+code
Del: spam -- https://master.php.net/note/delete/86111/spam
Del: non-english -- https://master.php.net/note/delete/86111/non-english
Del: in docs -- https://master.php.net/note/delete/86111/in+docs
Del: other reasons-- https://master.php.net/note/delete/86111
Reject -- https://master.php.net/note/reject/86111
Search -- https://master.php.net/manage/user-notes.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.