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 Quote Link to comment 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. Quote Link to comment 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". Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.