Created
December 13, 2012 17:00
-
-
Save mattonomics/4277944 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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