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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nadavvin
Forum Commoner
Posts: 68
Joined: Wed Sep 06, 2006 6:05 am

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

Post 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.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

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

Post by Celauran »

You don't. What is it you're trying to do?
phpdeveloper1
Forum Newbie
Posts: 19
Joined: Tue Aug 12, 2014 6:13 am
Location: Chennai, India

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

Post by phpdeveloper1 »

nadavvin wrote:[
echo isset($this) ? 'This Exist' : 'This Not Exist';
Maybe self:: would work ?
Chris, Php Developer and Programmer,
https://www.phpfreelanceprogrammer.com/
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

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

Post by requinix »

phpdeveloper1 wrote:Maybe self:: would work ?
Nope.
Post Reply