Page 1 of 1

How do I get $this from static function called dynamically?

Posted: Wed Sep 10, 2014 5:54 am
by nadavvin

Code: Select all


<?php

class A {
  public static function e() {
    echo "here\n";
    echo isset($this) ? 'This Exist' : 'This Not Exist';
    echo "\n";
  }

}

$a = new A();
$a->e();


it return This Not Exist


thanks.

Re: How do I get $this from static function called dynamical

Posted: Wed Sep 10, 2014 7:00 am
by Celauran
You don't. What is it you're trying to do?

Re: How do I get $this from static function called dynamical

Posted: Thu Sep 11, 2014 1:40 am
by phpdeveloper1
nadavvin wrote:[
echo isset($this) ? 'This Exist' : 'This Not Exist';
Maybe self:: would work ?

Re: How do I get $this from static function called dynamical

Posted: Thu Sep 11, 2014 2:16 am
by requinix
phpdeveloper1 wrote:Maybe self:: would work ?
Nope.