Re: [PHP4BETA] Implicit "this" pointers.
| From: | Faisal Nasim | Date: | Fri, 21 Apr 2000 06:34:28 +0000 |
| Subject: | Re: [PHP4BETA] Implicit "this" pointers. | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-13854@lists.php.net to get a copy of this message | ||
Hi,
If you don't put $this ->, then PHP would look them up
in the global function pool. You won't be able to call
the global functions with what you are requesting!
Consider this example:
class test
{
function test ()
{ myprint ( "Awesome" ); }
function myprint ( $str )
{ print "class: $str\n"; }
}
function myprint ( $str )
{ print "global: $str\n"; }
$test = new test;
If "$this ->" was not required, then the class's own
myprint() would have been called, and there would
be no way to call the global myprint() from the class.
Then we would need a $global (which doesn't exist
yet), to call the global functions:
$global -> myprint ( $str ); # not supported now
----- Original Message -----
From: "Szii" <szii@earthlink.net>
To: <php4beta@lists.php.net>
Sent: Friday, April 21, 2000 10:45 AM
Subject: [PHP4BETA] Implicit "this" pointers.
: Can we get them for objects, please please please?
:
: class me
: {
: var $something;
: function me()
: {
: wave(); #won't work! needs $this->
: SayHi(); #here either! needs $this->
: $something = "Does this work?" # won't work, needs $this->
: $this->wave(); #works
: }
: function SayHi()
: {
: echo "Hi!";
: }
: function wave()
: {
: echo "*wave*";
: }
: }
:
:
: It's very tedious to keep tying $this-> over and over. Maybe I'm
: just too spoiled on C++...
:
: -Szii
:
: --
: PHP 4.0 Beta Mailing List <http://www.php.net/version4/>
: To unsubscribe, e-mail: php4beta-unsubscribe@lists.php.net
: For additional commands, e-mail: php4beta-help@lists.php.net
: To contact the list administrators, e-mail: php4beta-admin@lists.php.net
:
: