Created
March 26, 2012 18:45
-
-
Save colindecarlo/2208624 to your computer and use it in GitHub Desktop.
A class method that is both a getter and a setter
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 | |
class ACDC { | |
protected $_data = null; | |
public function data() | |
{ | |
$args = func_get_args(); | |
if (!empty($args)) { | |
$this->_data = array_shift($args); | |
} | |
return $this->_data; | |
} | |
} | |
$acdc = new ACDC(); | |
$acdc->data('Hello World'); | |
echo $acdc->data(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment