user3176210
user3176210

Reputation: 41

how to nest single quotes into single quotes?

I want to nest a entry pop script into header, the whole code looks like -

<script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
$(document).ready(function()
{
    alert(\'Warning!\n\nClick OK to proceed.\');
});
</script>

And I need to nest that into the following code, in between the single quotes -

$snippet_b[1] = '';

How am I supposed to place the code?

Thanks a bunch for your help!

Upvotes: 1

Views: 97

Answers (2)

Hanky Panky
Hanky Panky

Reputation: 46900

So? Why not just do it. Your quotes are already escaped

<?php
$snippet_b[1] ='
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
    alert(\'Warning!\n\nClick OK to proceed.\');
});
</script>
';

echo $snippet_b[1];

?>

Upvotes: 3

troseman
troseman

Reputation: 1878

easiest way is to use the heredoc notation

http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc

$snippet_b[1] = <<<SNIPPET_B1

your code here, all quotes OK.

SNIPPET_B1;

Upvotes: 2

Related Questions