Skip to content

Instantly share code, notes, and snippets.

@clemherreman
Created June 15, 2011 13:56
Show Gist options
  • Save clemherreman/1027150 to your computer and use it in GitHub Desktop.
Save clemherreman/1027150 to your computer and use it in GitHub Desktop.
Static using non-static
<?php
Test::myStaticMethod();
//Output : Fatal error: Using $this when not in object context in /var/www/.../main.php on line XXX
<?php
class Test
{
private $message;
public function __construct()
{
$this->message = 'Omg this can be called?';
}
public static function myStaticMethod()
{
$this->myNotStatisMethod();
}
public function myNotStatisMethod()
{
echo $this->message;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment