Skip to content

Instantly share code, notes, and snippets.

@georgestephanis
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save georgestephanis/4a820a8df6a555951437 to your computer and use it in GitHub Desktop.
Save georgestephanis/4a820a8df6a555951437 to your computer and use it in GitHub Desktop.
~ $ php testforben.php
Foo/__construct called successfully.
Foo/non_static called successfully.
Foo/is_static called successfully.
Foo/is_static called successfully.
Strict Standards: Non-static method Foo::non_static() should not be called statically in /Users/georgestephanis/testforben.php on line 25
Foo/non_static called successfully.
~ $
<?php
error_reporting( E_ALL );
class Foo {
function __construct() {
echo __CLASS__ . '/' . __FUNCTION__ . ' called successfully.' . "\r\n";
}
function non_static() {
echo __CLASS__ . '/' . __FUNCTION__ . ' called successfully.' . "\r\n";
}
public static function is_static() {
echo __CLASS__ . '/' . __FUNCTION__ . ' called successfully.' . "\r\n";
}
}
$foo = new Foo();
$foo->non_static();
$foo->is_static();
Foo::is_static();
Foo::non_static();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment