Sorry for asking something that is widely documented, but I came across so many different approaches and I'm very, very confused.
public staticpublic $fooglobal, which seems to be a bad way of doing itdefine()const constant = 'constant value';Am I underestimating the complexity of what I'm trying to do here?
class MyClass
{
$foo = 'bar';
function DoStuff()
{
echo $foo;
}
} //MyClass
Class Example
{
private $foo = 5;
function bar()
{
echo $this->foo;
}
}
If it should be only available in your class I suggest this:
class MyClass {
private $foo = 'bar';
public function DoStuff() {
echo $this->foo;
}
}
if it should be available from other classes you should implement getter and setter.
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