In PHP, how can I achieve something like this from Python?
class CrowdProcess():
def __init__(self,variable):
self.variable = variable
def otherfunc(self):
print self.variable
PHP uses $this as a reference to the instance:
class CrowdProcess
{
public $variable;
public function __construct($variable)
{
$this->variable = $variable;
}
public function otherfunc()
{
echo $this->variable, PHP_EOL;
}
}
For more information, see http://php.net/language.oop5.basic#example-155
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With