Link to home
Start Free TrialLog in
Avatar of somits
somits

asked on

What does it means with $this-&gt

Hi:

I see the following code:

mysql_select_db($dbName, $this->dbConn) or die(mysql_error());

in a PHP class.

I don't understand $this-&gt

If you've some idea about this, please help.

Thanks,

Somits
SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Apparently the entity name has been transformed in my first sentence by Experts-Exchanges. The first sentence of my comment was:

"& g t ;" is the entity name of the "greater-than" character (http://www.w3schools.com/tags/ref_entities.asp).

Avatar of somits
somits

ASKER

Hi fcardinaux and angellll:

Thanks a lot for your reply. You give me the answer.

Would you give me some more info if you know?
\
Do you know why people write code in that way, instead explicitly writing $this->?

Is there anything wrong when writing $this->?

Thanks a lot,

Somits
>Is there anything wrong when writing $this->?
no. I prefer to use it, that way it's clearer when reading the code that you refer explicitly to a class variable/function.
Nobody writes code in this way. You're probably viewing it on a website that does something wrong with character escaping functions (http://www.php.net/manual/en/function.htmlspecialchars.php). It happens if you call the escaping function twice on the same string:

$var = '>';

// First time (correct)
$var = htmlspecialchars($var);
echo $var;   // Will send '& gt;' to the browser, which will display > on the webpage

// Second time (one time too many)
$var = htmlspecialchars($var);
echo $var;   // Will send '& amp;gt;' to the browser, which will display '& gt;' on the webpage

Avatar of somits

ASKER

Hi angellll and fcardinaux:

Thanks so much for your help.

It's clear to me now.

Somits