note 74376 added to language.oop5.visibility
| From: | nanocaiordo at gmail dot com | Date: | Sun, 08 Apr 2007 13:49:37 +0000 |
| Subject: | note 74376 added to language.oop5.visibility | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-125219@lists.php.net to get a copy of this message | ||
If you always thought how can you use a private method in php4 classes then try the following within
your class.
<?php
function private_func($func)
{
$this->file = __FILE__;
if (PHPVERS >= 43) {
$tmp = debug_backtrace();
for ($i=0; $i<count($tmp); ++$i) {
if (isset($tmp[$i]['function'][$func])) {
if ($this->file != $tmp[$i]['file']) {
trigger_error('Call to a private method '.__CLASS__.'::'.$func.' in
'.$tmp[$i]['file'], E_USER_ERROR);
}
}
}
}
}
?>
Then inside the private function add:
<?php
function foo() {
$this->private_func(__FUNCTION__);
# your staff goes here
}
?>
----
Server IP: 203.220.0.234
Probable Submitter: 202.173.180.252
----
Manual Page -- http://www.php.net/manual/en/language.oop5.visibility.php
Edit -- https://master.php.net/note/edit/74376
Del: integrated -- https://master.php.net/note/delete/74376/integrated
Del: useless -- https://master.php.net/note/delete/74376/useless
Del: bad code -- https://master.php.net/note/delete/74376/bad+code
Del: spam -- https://master.php.net/note/delete/74376/spam
Del: non-english -- https://master.php.net/note/delete/74376/non-english
Del: in docs -- https://master.php.net/note/delete/74376/in+docs
Del: other reasons-- https://master.php.net/note/delete/74376
Reject -- https://master.php.net/note/reject/74376
Search -- https://master.php.net/manage/user-notes.php