deathbeam
-
Posts
22 -
Joined
-
Last visited
Posts posted by deathbeam
-
-
Not sure what your talking about but php does have access modifiers
class phpfreak{ protected age; protected height; protected function getage(){ return $this->name; } protected function getheight(){ return $this->height; } } class create_freak extends phpfreak{ public function create_freak($age, $height){ $this->age = 20;//protected $this->height = 100;//Protected } public function get(){ return Array(parent::getage(), parent::getheight()); } } $create_a_freak = new create_freak();//calls constructor print_r($create_a_freak.get()); //gets valuesYes, it have protected, private and public. But it misses internal. Internal functions and vars are visible only in file.
-
Only thing I really miss from PHP is "internal" access modifier. Before I was making libraries and extensions in C# (like game frameworks, Tiled implementations, GUI loaders). Now, when I am working on my own PHP framework, I really miss internal, I was using it a lot in C#. Is internal planned to be added in PHP 7 or is it already in PHP 5.6 or it will never be added?
-
Notepad++ becouse my PC is too slow to handle PHPStorm


PHP "internal" access modifier
in Miscellaneous
Posted
There is also another scenario. Like this:
class base{ public function setParam($key, $callable){ $this->params[$key] = $callable; } internal function run(){ foreach($this->params as $key=>$callable) $callable(); } } $base = new Base(); // if internal was possible, users will not be able to call this method outside this file. Especially usefull for frameworks and PHP applications. $base->run();If you know what I mean. And yes, PHP isn´t C#, but PHP hosting is cheaper than ASP.NET. So it is pity that internal does not exists in PHP.