PHP Embed a HTML Tag (that has double & single quote marks) into a PHP echo statement.

I am trying to customize a HTML template (Porto from ThemeForrest).

For simplicity, I've only included the single line of HTML that's causing the problem:

Example:
<?php echo '
<div class="slider" id="revolutionSlider" data-plugin-revolution-slider data-plugin-options=\'{"startheight": 500}\'>
' ?>

Open in new window


I've tried escaping the single quotes inside the echo statement but that breaks the slider.

Does anyone have a work-around for this?   OR
Is there another way I can encapsulate the HTML so that it can be used on multiple pages using the PHP Include statement?

Thanks
Graham
GrahamPoleAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongCommented:
you can try:

<?php echo "<div class='slider' id='revolutionSlider' data-plugin-revolution-slider data-plugin-options='{\"startheight\":500}'>" ?>
0
GrahamPoleAuthor Commented:
Thanks Ryan... This still breaks the Slider!
0
Ryan ChongCommented:
what about this?

<?php echo "<div class=\"slider\" id=\"revolutionSlider\" data-plugin-revolution-slider data-plugin-options='{\"startheight\": 500}'>" ?>
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

Dave BaldwinFixer of ProblemsCommented:
Try this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<title>PHP Quote test</title>
</head>
<body>
<h1>PHP Quote test</h1>
<?php 
$echostr = <<<EOS
<div class="slider" id="revolutionSlider" data-plugin-revolution-slider data-plugin-options='{"startheight": 500}'>
EOS;
echo $echostr;
 ?>
</body>
</html>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
GrahamPoleAuthor Commented:
Hi Dave,

Your suggestion solved my problem.


Thanks,
Graham
0
GrahamPoleAuthor Commented:
Hi Ryan,

Thanks again for your suggestion... I had tried that strategy before posting the original question. Unfortunately, escaping any of the quotes results in breaking the slider...

<?php echo "<div class=\"slider\" id=\"revolutionSlider\" data-plugin-revolution-slider data-plugin-options='{\"startheight\": 500}'>" ?>"

Open in new window

The above strategy breaks the slider.

Dave Baldwin came up with a solution... See above post.

Thanks
Graham
0
Ray PaseurCommented:
For a deeper understanding of how quotes work in PHP, we have this article:
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_12241-Quotation-Marks-in-PHP.html

Going forward, you can post your future questions in more than one "Zone" so if there is something like WordPress involved, you can add the WordPress Zone, HTML Zone, etc.  This may get more eyes on the questions.  Just a thought...
0
Dave BaldwinFixer of ProblemsCommented:
Graham, please close out this question by accepting my comment above as the solution and awarding points to me for it.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.