Skip to content

Instantly share code, notes, and snippets.

@mattonomics
Created December 13, 2012 17:00
Show Gist options
  • Save mattonomics/4277944 to your computer and use it in GitHub Desktop.
Save mattonomics/4277944 to your computer and use it in GitHub Desktop.
<?php
class super_kewl {
// can be public or no visibility declaration (which defaults to public)
public function matt($param = false) {
echo $param ? esc_attr($param) : 'Hello!';
}
}
// will output Hello
super_kewl::matt();
// or, if you want it to look different
function matt_is_kewl($param) {
super_kewl::matt($param);
}
matt_is_kewl();
// however, if you have $this, you can't do that
class bad_code {
private $property = 'Hello';
public function bad_method($param = false) {
echo $this->property . ($param ? esc_attr($param) : ' World!');
}
}
// will fail
bad_code::bad_method();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment