Created
April 12, 2012 08:39
-
-
Save nauman/2365647 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
//static variable make place in memory without initialization the object\ | |
//static functions are class level function not object level, they cant access object level | |
class YourClass | |
{ | |
protected $_attribute; | |
public function __construct() { | |
$this-> _attribute = 10; | |
echo $this -> _attribute; | |
} | |
public function yourStaticMethod() { | |
echo $this -> _attribute % 5; | |
echo "\n"; | |
echo $this -> _attribute; | |
} | |
} | |
$obj = new YourClass(); | |
$obj -> yourStaticMethod(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment