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->
If you've some idea about this, please help.
Thanks,
Somits
I see the following code:
mysql_select_db($dbName, $this->dbConn) or die(mysql_error());
in a PHP class.
I don't understand $this->
If you've some idea about this, please help.
Thanks,
Somits
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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.
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
$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
ASKER
Hi angellll and fcardinaux:
Thanks so much for your help.
It's clear to me now.
Somits
Thanks so much for your help.
It's clear to me now.
Somits
"& g t ;" is the entity name of the "greater-than" character (http://www.w3schools.com/tags/ref_entities.asp).