SevenAteAnthony
asked on
Escape Quotes in a PHP Variable
Hi Experts,
Thanks for reading. I'm looking for some advice. In regards to escaping quotes in a variable, is the following okay to do in place of the second code?
Is the first code the best practice? Do you have a better suggestion? Any advice is appreciated.
Thanks!
Thanks for reading. I'm looking for some advice. In regards to escaping quotes in a variable, is the following okay to do in place of the second code?
$variable = '<div class="box">User\'s Info</div>';
$variable = "<div class=\"box\">User's Info</div>";
Is the first code the best practice? Do you have a better suggestion? Any advice is appreciated.
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Don't you need to use the dot either way?
<?php
$myvar1 = "linktosomeImage";
echo $myvar1 . " <br />";
$myvar2 = ' → <a href="'.$myvar1.'" rel="nofollow" title="a little tip here">Right-Click this Link to Save Image</a>';
echo $myvar2;
?>
Nope. See Variable parsing on http://us3.php.net/manual/en/language.types.string.php#language.types.string.syntax.double
ASKER
Thank you.
You're welcome, glad to help.
ASKER