note 86111 added to language.oop5.magic
| From: | jon at webignition dot net | Date: | Fri, 03 Oct 2008 14:26:53 +0000 |
| Subject: | note 86111 added to language.oop5.magic | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-145018@lists.php.net to get a copy of this message | ||
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