# Re[2]:  Re: hook cast_object handler in userspace

- Thread: https://externals.io/message/3716
- Original archive: https://news-web.php.net/php.internals/3716
- Started by Simeon Koptelov on 2003-08-04T12:33:00+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #3716 — Simeon Koptelov — 2003-08-04T12:33:00+00:00

URL: https://externals.io/message/3716#3716

Hello Cristiano,

Monday, August 4, 2003, 8:45:20 AM, you wrote:

> > […]
CD> "__tostring()" ?

Maybe the __tostring() will be the best because few naming
conventions for methods exist. Some people prefer C-like some_method(), some
like Java-like someMethod() etc. But there is already in PHP5
pre-defined methods like __clone, __construct, __destruct so the
"__tostring" name will be expected by user. The "__to_string" will
also be though. I have seen no "__" methods with names having two
words so this variants are equal from my point of view.

CD> I modified the code to just call to_string if the object implements the
CD> "printable" interface.

The printable is IMHO definetly not good name for such interface. When
user sees the "implements Printable" he expects methods like
print(), println() etc. that do something, not return strings.
I can't name this interface better though.
Maybe it will be better to have this method in all classes and define
default behavior such as existing ( string )$object cast?

-- 
Best regards,
 Simeon                            mailto:xi@newmail.ru
