Welcome Guest, Not a member yet? Register   Sign In
$function() ?
#4

[eluser]Colin Williams[/eluser]
It needs to be like 'method' and you actually do $this->$method(). Sorry I wasn't clear about that.

Here's an example of securing methods that can be called with an array.

Code:
class Example extends Model {

  var $allowed_actions;
  
  function Example()
  {
    $this->allowed_actions = array('bake', 'frost', 'eat');
  }

  function recipe()
  {
    // Get the recipe action somehow and store it in $action...
    if (in_array($action, $this->allowed_actions) and method_exists($this, $action))
    {
      $this->$action();
    }
    else
    {
      show_error('Action does not exist or is not allowed');
    }
  }

  function bake()
  {

  }

  [...]

}


Messages In This Thread
$function() ? - by El Forum - 09-01-2008, 12:21 AM
$function() ? - by El Forum - 09-01-2008, 12:41 AM
$function() ? - by El Forum - 09-01-2008, 01:14 AM
$function() ? - by El Forum - 09-01-2008, 01:19 AM
$function() ? - by El Forum - 09-01-2008, 01:26 AM



Theme © iAndrew 2016 - Forum software by © MyBB