The following works just fine. But I need to add something that has quotes in it.
echo "<p class='verticaltext'>" . $name_char . "</p>";
The problem is that the whole echo statement has to be in double quotes “ and anything inside of that that would normally be in double quotes in HTML has to be in single quotes. Well what about something in that that would be in single quotes?
In regular HTML I would do this:
<p class=”verticaltext” onmouseover=”this.style.color=’red’”>Some Text To Display</p>
The word red is in single quotes.
I need this:
echo "<p class='verticaltext' onmouseover='this.style.color=red'>Some Text To Display</p>"
but "red" has to be quoted.
When you use echo on it you put all of it in doubles and turn the doubles into singles. But what do you do with the singles? I tried using multiple single quotes and also tried just taking them out. Nothing worked. How is this done?
html to php - dealing with quotes problem
Moderator: General Moderators
Re: html to php - dealing with quotes problem
do this...
echo <<<HTML
<div id="whatever">Hello World</div>
HTML;
Or if you want to put it into a variable...
$var = <<<HTML
<div id="whatever">Hello World</div>
HTML;
echo <<<HTML
<div id="whatever">Hello World</div>
HTML;
Or if you want to put it into a variable...
$var = <<<HTML
<div id="whatever">Hello World</div>
HTML;
Re: html to php - dealing with quotes problem
Thanks for the info. I couldn't get that to work. Blank page. But this works:
echo "<p class='verticaltext' onmouseover='this.style.color="red"'>" . $name_char . "</p>";
echo "<p class='verticaltext' onmouseover='this.style.color="red"'>" . $name_char . "</p>";
Re: html to php - dealing with quotes problem
did you put a new line after the HTML; ???
You server was prolly tossing out an error...
You server was prolly tossing out an error...
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: html to php - dealing with quotes problem
There are several ways to do this. You can use single quotes inside of double quotes or the other way around. If you need singles in singles or doubles in doubles etc. then you need to escape them:
Code: Select all
echo 'something \'something\' and "something else" something';
//or
echo "something 'something' and \"something else\" something";mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: html to php - dealing with quotes problem
Turns out escaping is the best way for what I'm trying to do. Took some doing to figure out what to escape and what not to escape but it's working nicely. Thanks.