On Aug 3, 2007, at 2:38 AM, Ralph Kutschera wrote:

Hallo!

I'm working on a project, where we distinguish between "functions" and "actions" in design, although in PHP both are implemented as functions.
Is there a chance that PHP can use the word "action" as "function"?

E.g.:
public function doSomething() { .... }
public action doSomethingElse() { ... }

... is actually the same but would help to see the design also in the code.

You could define a generic action function

function action($funcName, $funcArgs)
{
        return $funcName($funcArgs);
}

and use it on any function you want to use as an action function

function printColor($color) {
        echo 'color: '.$color.'<br>';
}

function printArea($width, $height) {
        echo 'area: '.($width * $height).'<br>';
}

action('printColor', 'blue');
action('printArea', 3, 5);

You could then pass in any function that is visible to the action function. You lose some efficiency but get your action function

Then again, you could also just prepend action functions with 'action_'



TIA, Ralph

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to