free html hit counter
Check if current function called statically or not
Check if current function called statically or not
2019-12-03 / Dimas Lanjaka Kumala Indra

$static = !(isset($this) && get_class($this) == __CLASS__);
if ($static) {
return self;
} else {
return $this;
}
in class example:
class Foo {
function bar() {
$static = !(isset($this) && get_class($this) == __CLASS__);
if ($static) {
return self;
} else {
return $this;
}
}
}
or simply create below function to test:

class A
{
function foo()
{
if (isset($this)) {
echo '$this is defined (';
echo get_class($this);
echo ")\n";
} else {
echo "\$this is not defined.\n";
}
}
}
How do I check in PHP that I'm in a static context (or not)? Check if current function called statically or not

Check if current function called statically or not

PermaLink: https://www.webmanajemen.com/2019/12/check-if-current-function-called.html
Incoming search terms for Check if current function called statically or not:
  • Check if current function called statically or not
  • Check if current function called statically or not WMI Gitlab

Google Rich Snippets | Schema Markup Validator | Google Pagespeed Insight