note 80337 deleted from language.oop5.overloading by levim
| From: | levim@php.net | Date: | Mon, 16 Nov 2015 01:55:46 +0000 |
| Subject: | note 80337 deleted from language.oop5.overloading by levim | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-204156@lists.php.net to get a copy of this message | ||
Note Submitter: soldair at NOSPAM gmail.com
----
the documentation states a falsehood:
"All overloading methods must be defined as public."
<?php
class test{
#################
#public use methods#
#################
public static function echoData(){
$obj = self::getInstance();
echo $obj->find('data');
return true;
}
######################
#only use a single instance#
######################
private static $instance;
private static function getInstance(){
if(!isset(self::$instance)){
self::$instance = new test;
}
return self::$instance;
}
#################
#private instantiation#
#################
private $data = array('data'=>'i am data');
private function __construct(){}
private function __call($nm,$args){
if(isset($this->data[$args[0]])){
return $this->data[$args[0]];
}
return null;
}
}
test::echoData();
?>
--------------OUTPUT---------------
i am data
-----------------------------------
this test was run using PHP Version 5.2.4