Solved

What does it means with $this-&gt

Posted on 2009-07-04
7
357 Views
Last Modified: 2012-05-07
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
0
Comment
Question by:somits
  • 3
  • 2
  • 2
7 Comments
 
LVL 142

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 150 total points
Comment Utility
$this->
refers to the object (calls) itself.




0
 
LVL 8

Accepted Solution

by:
fcardinaux earned 350 total points
Comment Utility
> 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.
0
 
LVL 8

Expert Comment

by:fcardinaux
Comment Utility
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).

0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Comment

by:somits
Comment Utility
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
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
>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.
0
 
LVL 8

Expert Comment

by:fcardinaux
Comment Utility
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

0
 

Author Comment

by:somits
Comment Utility
Hi angellll and fcardinaux:

Thanks so much for your help.

It's clear to me now.

Somits
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
This article discusses four methods for overlaying images in a container on a web page
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now