Jump to content

CodeBuilder

New Members
  • Posts

    1
  • Joined

  • Last visited

Posts posted by CodeBuilder

  1. 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.

    i think you can use "final" for that...  

    class base{

    public function setParam($key, $callable){

    $this->params[$key] = $callable;

    }

    final function run(){

    foreach($this->params as $key=>$callable)

    $callable();

    }

    }

     

    If you use like this then you cannot modify this method in any derived classes..

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.