Hi All,

Just a thought, but while working reciently with a few ECMA scripting
languages (eg: ActionScript in Flash MX), I uncovered the amazing uses
(especially from a security point of view) of variable functions.

For those that dont know, it allows you to assign a function to a
variable, rather than to declare it globally, for example:

<?php

  function test ($param, $default=false) {
    // stuff goes here
  }
  test("my param");

  /* could also be written as */

  $func_test = function ($param, $default) {
    // stuff goes here
  }
  $func_test("my param", true);

  /* removing a function could then be */

  unset($func_test);

?>

Any form of variable or constant would be able to be used (eg: a function
inside of an array, or a class method as a property). This would allow the
very very simple usage of "getter-setters", as they are called in flash.

EG: You may have the properties $user->birthdate and $user->age, where you
want the age to be pulled dynamically. At the moment you have to define
$user->age(), but the following code could be used:

<?php

  class user {
    var $birthdate = "YYMMDDHH";
    var $age = function {
      // Code to get birthdate
      $myAge = // .... // ;
      // Return the age
      return $myAge;
    }
  }

?>

This may or may not fit into the way PHP is going, but its just an idea -
and ideas have never been frowned upon, (nor should they be!)

I think that puts across the general gist of my suggestion... any thoughts
or comments on the idea?


-- 
Dan Hardiker [[EMAIL PROTECTED]]
ADAM Software & Systems Engineer
First Creative



-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to