GrahamPole
asked on
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:
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
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}\'>
' ?>
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
ASKER
Thanks Ryan... This still breaks the Slider!
what about this?
<?php echo "<div class=\"slider\" id=\"revolutionSlider\" data-plugin-revolution-sli der data-plugin-options='{\"st artheight\ ": 500}'>" ?>
<?php echo "<div class=\"slider\" id=\"revolutionSlider\" data-plugin-revolution-sli
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 Dave,
Your suggestion solved my problem.
Thanks,
Graham
Your suggestion solved my problem.
Thanks,
Graham
ASKER
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...
Dave Baldwin came up with a solution... See above post.
Thanks
Graham
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}'>" ?>"
The above strategy breaks the slider.Dave Baldwin came up with a solution... See above post.
Thanks
Graham
For a deeper understanding of how quotes work in PHP, we have this article:
https://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...
https://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...
Graham, please close out this question by accepting my comment above as the solution and awarding points to me for it.
<?php echo "<div class='slider' id='revolutionSlider' data-plugin-revolution-sli