How to have a PHP variable with HTML wrapped inside of JavaScript with both single quotes and double quotes already used
Get the solution ↓↓↓How to have a PHP variable with HTML wrapped inside of JavaScript with both single quotes and double quotes already used. I've tried escaping them, but it is just breaking it.
$html_php = "
'<div class=\"release-timer-div\" id=\"days\">Next Release <span class=\"release-timer-span\">.</span></div><div class=\"release-timer-div\" id=\"days\">' + days + '<span class=\"release-timer-span\">days</span></div><div class=\"release-timer-div\" id=\"hours\">' + hours + '<span class=\"release-timer-span\">hrs</span></div><div class=\"release-timer-div\" id=\"minutes\">' + minutes + '<span class=\"release-timer-span\">min</span></div><div class=\"release-timer-div\" id=\"seconds\">' + seconds + '<span class=\"release-timer-span\">sec</span></div>'
";
Answer
Solution:
you can't combine like that, i recomend you to use pure php script in code bellow using "." and $(variable) to combine text , and using js after hole html is render on page so you can manipulate using id of element or class name.
$var = '<div class="release-timer-div" id="days">Next Release <span class="release-timer-span">.</span></div><div class="release-timer-div" id="days">'.$day.'<span class="release-timer-span">days</span></div><div class="release-timer-div" id="hours">'.$hour.'<span class="release-timer-span">hrs</span></div><div class="release-timer-div" id="minutes">'.$minutes.'<span class="release-timer-span">min</span></div><div class="release-timer-div" id="seconds">'.$seconds.'<span class="release-timer-span">sec</span></div>';
if you're using api call, just using js for render the page. dont combine between 2 language it too complicated. hope this answer your question.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: npm err! code 1
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.