Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

What does it means with $this-&gt

Posted on 2009-07-04
7
Medium Priority
?
365 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 143

Assisted Solution

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




0
 
LVL 8

Accepted Solution

by:
fcardinaux earned 1400 total points
ID: 24777652
> 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
ID: 24777658
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:somits
ID: 24777673
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 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24777699
>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
ID: 24777709
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
ID: 24777725
Hi angellll and fcardinaux:

Thanks so much for your help.

It's clear to me now.

Somits
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

609 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