note 70651 added to language.oop5
It's easy to create a simple emulation of the namespaces or packages support available in java, c++, etc...
<?php
class myPackage {
public function myPublicClassEmu() {
$this->myPrivateClassEmu();
}
private function myPrivateClassEmu() {
$this->myProtectedClassEmu();
}
protected function myProtectedClassEmu() {
function myPrivateFunction() {
echo 'test';
}
return myPrivateFunction();
}
}
$MyPackage = new myPackage(); // or: new myPackage
$MyPackage->myPublicClassEmu();
?>
This will output:
test
Off course this isn't the same as the namespaces in C++, but does provide the same functionality idea
----
Server IP: 194.109.193.119
Probable Submitter: 81.207.175.146
----
Manual Page -- http://www.php.net/manual/en/language.oop5.php
Edit -- https://master.php.net/note/edit/70651
Del: integrated -- https://master.php.net/note/delete/70651/integrated
Del: useless -- https://master.php.net/note/delete/70651/useless
Del: bad code -- https://master.php.net/note/delete/70651/bad+code
Del: spam -- https://master.php.net/note/delete/70651/spam
Del: non-english -- https://master.php.net/note/delete/70651/non-english
Del: in docs -- https://master.php.net/note/delete/70651/in+docs
Del: other reasons-- https://master.php.net/note/delete/70651
Reject -- https://master.php.net/note/reject/70651
Search -- https://master.php.net/manage/user-notes.php
|