What does it means with $this-&gt


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.


Who is Participating?
fcardinauxConnect With a Mentor Commented:
> is the entity name of the "greater-than" character (http://www.w3schools.com/tags/ref_entities.asp).

So, what you see is this code: :

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

It has simply been transformed by a character escaping function.
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
refers to the object (calls) itself.

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).

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

somitsAuthor Commented:
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,

Guy Hengel [angelIII / a3]Billing EngineerCommented:
>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

somitsAuthor Commented:
Hi angellll and fcardinaux:

Thanks so much for your help.

It's clear to me now.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.