Re: [PHP] Object method overloading
What is the point of overloading an object again? Hello, I realize this stuff isn't set in stone yet, but might I eventually expect the following to make two assignments rather than one? ?php class overload_test { function __set($name, $value) { echo __set($name, $value)\n; $this-$name = $value; return true; } } overload('overload_test'); $t = new overload_test; $t-a = 'Foo'; $t-b[0] = 'Bar'; print_r($t); ? Output: __set(a, Foo) overload_test Object ( [a] = Foo ) Thanks, -Dan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Object method overloading
Hello, I realize this stuff isn't set in stone yet, but might I eventually expect the following to make two assignments rather than one? ?php class overload_test { function __set($name, $value) { echo __set($name, $value)\n; $this-$name = $value; return true; } } overload('overload_test'); $t = new overload_test; $t-a = 'Foo'; $t-b[0] = 'Bar'; print_r($t); ? Output: __set(a, Foo) overload_test Object ( [a] = Foo ) Thanks, -Dan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Object method overloading
Well, for instance, you could have the __get and __set functions execute a SQL query or go to a file or whatever. The point, as it seems to me anyway, is to enable a potentially complex internal implementation be exposed with a simple interface. Now as for the implications of that, it's debatable. If nobody is ever going to look at or reuse your code, it's arguable such a feature merits a second glance. Personally, I appreciate these kinds of language features, but perhaps that's because I learned most of what I know about programming in C++. Thanks, -Dan [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] What is the point of overloading an object again? Hello, I realize this stuff isn't set in stone yet, but might I eventually expect the following to make two assignments rather than one? ?php class overload_test { function __set($name, $value) { echo __set($name, $value)\n; $this-$name = $value; return true; } } overload('overload_test'); $t = new overload_test; $t-a = 'Foo'; $t-b[0] = 'Bar'; print_r($t); ? Output: __set(a, Foo) overload_test Object ( [a] = Foo ) Thanks, -Dan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] object method overloading
can you do method overloading in php as you can in java? Javier _ Protect your PC - get McAfee.com VirusScan Online http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php