Too much magic ?
| From: | l0t3k | Date: | Wed, 22 Oct 2003 01:53:30 +0000 |
| Subject: | Too much magic ? | ||
| Groups: | php.pecl.dev | ||
| Request: | Send a blank email to pecl-dev+get-141@lists.php.net to get a copy of this message | ||
hey ya'll,
i'm working on an I18N extension for PHP5 which takes full advantage of the
new OOP support in ZE2, including the cast handler. right now you can do
something like this :
I18N_SetOutputEncoding("Latin-1"); /* set global
output encoding */
$unistring = new UnicodeString( $sjisString, "sjis"); /* convert from
sjis to Unicode */
echo "Latinized string : $unistring"; /* uses the cast handler to
convert $unistring to latin1 */
my question is - is this too much magic, and can it come back to bite me in
the butt ? i think it makes sense in this instance, but i think generally
string casts of objects (in Java especially) are used primarily to get a
representation for debugging rather than end-user output (IOW, give an
indication of internal state). another example (not yet implemented) is as
follows :
$cal = Calendar::createInstance(TimeZone::getDefault(),
Locale::getFrench());
echo "Current time is : $cal \n"; /* mardi 21 octobre 2003 07 h 35
GMT-04:00, output in Latin1 */
this seems in the spirit of PHP, but i want to know if people can spot
possible drawbacks.
l0t3k