Re: [PHP] $this objects and vars
on 1/18/02 8:58 AM, TD - Sales International Holland B.V. at [EMAIL PROTECTED] wrote: > now further in the script you'll get an sql query > $this = mysql_fetch_array(indentifier); > > now as far as I knew you shouldn't be possible to use $this for this purpose, > it has nothing to do with objects... why can it be used? it's only confusing > things. The script works tho... this is only a guess, but maybe separate namespaces. one is an array and one is an object. the object $this should only exist inside a method definition, right? $this outside of that context isn't referring to itself at that point but some memory space allocated to the variable named 'this' instead, i guess. ? mike -- mike cullerton michaelc at cullerton dot com -- PHP General 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] $this objects and vars
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 * On 18-01-02 at 17:00 * TD - Sales International Holland B.V. said > > Hey there, > > got a question about $this. I thought this was a fixed variable to point to > the currently used object but I've seen a script wherein it's used within an > object like this > > class a { > $var = 0; > > function b { > do something... > $this ->var++; > } > } > > the $this here will increment the $var of the object a... so far so good. > > now further in the script you'll get an sql query > $this = mysql_fetch_array(indentifier); Looks to me like $this is just an ordinary var as it not being used with the pointer thingy (->) Nick Wilson Tel:+45 3325 0688 Fax:+45 3325 0677 Web:www.explodingnet.com -BEGIN PGP SIGNATURE- Version: GnuPG v1.0.6 (GNU/Linux) iD8DBQE8SEjkHpvrrTa6L5oRArB8AKCUrW7gCVlEF51wXKQO2yY+TIaBLACcDTgX IPYbBSPO6fDvZH8fvXlEmyM= =/t2J -END PGP SIGNATURE- -- PHP General 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] $this objects and vars
Hey there, got a question about $this. I thought this was a fixed variable to point to the currently used object but I've seen a script wherein it's used within an object like this class a { $var = 0; function b { do something... $this ->var++; } } the $this here will increment the $var of the object a... so far so good. now further in the script you'll get an sql query $this = mysql_fetch_array(indentifier); now as far as I knew you shouldn't be possible to use $this for this purpose, it has nothing to do with objects... why can it be used? it's only confusing things. The script works tho... As far as I've seen in other languages, the things the language contains can't be used for something else (think they're called language constructs?!) anyways it would be sortta like trying to define a function print while one already exists natively in the language. You shouldn't be able to do that right? Does anyone mind explain why $this can be used as a normal var? this is very confusing. And what is php gonna do if you have a var $this and use $this to point to the current object? Kind regards and have a nice weekend --- -- PHP General 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]