Jump to content

What's the difference between 2 classes?


Recommended Posts

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

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".

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.