programming.name Posted May 12, 2010 Share Posted May 12, 2010 Hi, There are two classes; a and b. class a { private $a; public function method_a($_a) { return $a = $_a; } } $var = new a(); echo $var->method_a("Some value"); class b { private $b; public function method_b($_b) { return $this->b = $_b; } } $var = new b(); echo $var->method_b("Some value"); What is the real difference between two classes? Thanks Link to comment https://forums.phpfreaks.com/topic/201458-whats-the-difference-between-2-classes/ Share on other sites More sharing options...
trq Posted May 12, 2010 Share Posted May 12, 2010 Nothing really, there both incorrectly returning a bool. Link to comment https://forums.phpfreaks.com/topic/201458-whats-the-difference-between-2-classes/#findComment-1056936 Share on other sites More sharing options...
ignace Posted May 12, 2010 Share Posted May 12, 2010 Nothing really, there both incorrectly returning a bool. he uses = that doesn't return a bool rather the assigned value (in this case a string). See, VB is bad for your health. What is the real difference between two classes? In the second you assign the value to an internal class variable. Both return your input "Some value". Link to comment https://forums.phpfreaks.com/topic/201458-whats-the-difference-between-2-classes/#findComment-1056986 Share on other sites More sharing options...
trq Posted May 12, 2010 Share Posted May 12, 2010 he uses = that doesn't return a bool rather the assigned value (in this case a string). See, VB is bad for your health. Oh, indeed it does. I would have assumed it would have returned a bool based on whether or not the assignment worked or not. Link to comment https://forums.phpfreaks.com/topic/201458-whats-the-difference-between-2-classes/#findComment-1056993 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.