Solved

What does it means with $this-&gt

Posted on 2009-07-04
7
359 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
ID: 24777553
$this->
refers to the object (calls) itself.




0
 
LVL 8

Accepted Solution

by:
fcardinaux earned 350 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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 

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 142

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
designing in object programming 12 80
How to properly use session_regenerate_id when user logs in 7 45
000webhost.com default error log 1 29
PHP Installer 5 28
This article discusses four methods for overlaying images in a container on a web page
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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…

825 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