Re: [PHP-DEV] More OOP

2001-01-18 Thread Alexander Wirtz

Hi Tom,

>I looked at your link "http://www.mm4.de/php4win/tips.php3?id=1" and found
>that "parent::classname()" worked. But how? Usualy PHP uses a "->" like
>"$this->classname()". I've never before seen the two "::" - Can someone
>explain?

This syntax is borrowed from C++ (or Java) and is a way to access methods
of classes which have no instance. This is also called a static method.
So if you have

class myclass
{
   function myfunction()
   {
  ...
   }
}

you can access this function via "myclass::myfunction()", even if there is
no object instantiated. "parent" is a reserved word to access functions of
the superclass.

(I hope I got everything right ;-)

Regards
   Alex

-- 
| Alexander Wirtz   | eMail: [EMAIL PROTECTED]|
| web@ctive GmbH| WWW:   http://www.web-active.com   |

-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DEV] More OOP

2001-01-18 Thread Cynic

probably not documented yet

At 14:39 18.1. 2001, Sam Liddicott wrote the following:
-- 
>> see $parent
>
>I can't find reference to this on the site, although
>http://www.php.net/manual/en/ref.classobj.php seems very useful.
>
>Sam

Cynic


-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] More OOP

2001-01-18 Thread Thomas Watson

Hi

I looked at your link "http://www.mm4.de/php4win/tips.php3?id=1" and found
that "parent::classname()" worked. But how? Usualy PHP uses a "->" like
"$this->classname()". I've never before seen the two "::" - Can someone
explain?

- It works though... thanks :)

/watson

- Original Message -
From: "Harald Radi" <[EMAIL PROTECTED]>
To: "Sam Liddicott" <[EMAIL PROTECTED]>; "Cynic" <[EMAIL PROTECTED]>;
"Thomas Watson" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Thursday, January 18, 2001 3:05 PM
Subject: AW: [PHP-DEV] More OOP


> see http://www.mm4.de/php4win/tips.php3?id=1
>
> > -Ursprüngliche Nachricht-
> > Von: Sam Liddicott [mailto:[EMAIL PROTECTED]]
> > Gesendet: Donnerstag, 18. Jänner 2001 14:39
> > An: Cynic; Sam Liddicott; Thomas Watson; [EMAIL PROTECTED]
> > Betreff: RE: [PHP-DEV] More OOP
> >
> >
> >
> >
> > > -----Original Message-
> > > From: Cynic [mailto:[EMAIL PROTECTED]]
> > > Sent: Thursday, January 18, 2001 01:41
> > > To: Sam Liddicott; Thomas Watson; [EMAIL PROTECTED]
> > > Subject: RE: [PHP-DEV] More OOP
> > >
> > >
> > > At 14:27 18.1. 2001, Sam Liddicott wrote the following:
> > > --
> > > >Sounds a good idea.  $super though is identical to $this in
> > > plain value but
> > > >has a different type.
> > > >For $super you mean $this but treated as if it were a parent
> > > class.  Maybe
> > > >this will be introduced soon.
> > >
> > > see $parent
> >
> > I can't find reference to this on the site, although
> > http://www.php.net/manual/en/ref.classobj.php seems very useful.
> >
> > Sam
> >
> >
> >
> >
> > --
> > PHP Development Mailing List <http://www.php.net/>
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
> >
>
>


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DEV] More OOP

2001-01-18 Thread Sam Liddicott



> -Original Message-
> From: Cynic [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 18, 2001 01:41
> To: Sam Liddicott; Thomas Watson; [EMAIL PROTECTED]
> Subject: RE: [PHP-DEV] More OOP
> 
> 
> At 14:27 18.1. 2001, Sam Liddicott wrote the following:
> -- 
> >Sounds a good idea.  $super though is identical to $this in 
> plain value but
> >has a different type.
> >For $super you mean $this but treated as if it were a parent 
> class.  Maybe
> >this will be introduced soon.
> 
> see $parent

I can't find reference to this on the site, although
http://www.php.net/manual/en/ref.classobj.php seems very useful.

Sam




-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DEV] More OOP

2001-01-18 Thread Cynic

At 14:27 18.1. 2001, Sam Liddicott wrote the following:
-- 
>Sounds a good idea.  $super though is identical to $this in plain value but
>has a different type.
>For $super you mean $this but treated as if it were a parent class.  Maybe
>this will be introduced soon.

see $parent


-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DEV] More OOP

2001-01-18 Thread Sam Liddicott



> -Original Message-
> From: Thomas Watson [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 18, 2001 12:35
> To: [EMAIL PROTECTED]
> Subject: [PHP-DEV] More OOP
> 
> 1: If you are overriding an existing method in a class, it is then not
> possible to call the original method. Its a very basic thing 
> in OOP and
> should be possible. This is allowed in other languages such as C++ and
> Java. In Java this is done by using the super var. (In java 
> they also have
> the "this" var. The "super" var. is identical to "this" 
> whereas it just
> calls the overridden method).

Sounds a good idea.  $super though is identical to $this in plain value but
has a different type.
For $super you mean $this but treated as if it were a parent class.  Maybe
this will be introduced soon.

> 2: It would also be great if PHP supported methods with the 
> same name but
> with different arguments. I'm not sure if this is possible in 
> a language
> such as PHP, because that you don't have to assign a type 
> (int, char) to a
> variable (like you do in Java and C/C++ and most other 
> compiled languages).

As you indicate it will be difficult to do automatically, however you can do
as perl does and just analyse the arguments yourself and then call a
different internal implementation.

function foo($foo1,$foo2=FALSE) {
  if ($foo1 == "oik") return $this->_foo_1($foo1,$foo2);
  else return $this->_foo_2($foo1,$foo2,"bink");
}

You can also make use of func_get_args when writing your own dispatcher
(http://www.php.net/manual/en/function.func-get-args.php)

This would me more clear than anything you could hope to get in a type-free
language.

> 
> If you like me to explain my questions more in depth then just reply.
> 
> /watson
> 
> -- 
> PHP Development Mailing List 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: 
> [EMAIL PROTECTED]
> 

-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]