Well, that is what I think that I need. Please let me explain what I am trying 
to do
and tell me how to do it or a better way of doing it.

I have an application where a Screen (web page) may contain several Forms. The 
will want to access properties, etc, from their Screen. So what I want is to do
something like:

class Screen {
    private $JavascriptVars = array();

    function AddJsVar($name, $val) {
      $this->JavascriptVars[$name] = $val;

class Form extends Screen {
    public $screen;  // Could set to a class Screen

    function DefineForm($fName)

$s = new Screen(....);
$s->AddJsVar('Date', '15 Oct 2011');

$f1 = new Form($s);
$f1->AddJsVar('CompanyName', 'IBM');

$f2 = new Form($s);
$f2->AddJsVar('Error', 'Login failed');

The trouble is that $f1->AddJsVar() will fail, class extention seems not 
designed to work like that.

I could make it work by either:

1) $f1->screen->AddJsVar() --- but I would rather avoid the extra '->screen'.

2) Use of a __call() in class Form -- but that makes things slower.

Any help gratefully received.

I think that to do what I want PHP would need a syntax like:

    $f2 = new $s Form();
    $f2 = $s->new Form();

Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT 
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: 
#include <std_disclaimer.h>

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

Reply via email to