Jump to content

printing a script


grlayouts

Recommended Posts

Hi,

 

I really need to find a way to print the code below in php.

 

 <script>
$(document).ready(function()
  {
    $.sticky('The page has loaded!');
  });
</script>

 

i tried

 

print"<script>
$(document).ready(function()
  {
    $.sticky('The page has loaded!');
  });";
</script>

 

any help would be great. :)

Link to comment
https://forums.phpfreaks.com/topic/260152-printing-a-script/
Share on other sites

This should work:

 

<?php
print"<script>
$(document).ready(function()
  {
              $.sticky('The page has loaded!');
                });
</script>";
?>

 

Or you can just put the code outside php tags altogether.  Also be careful of using "$" inside a print statemente - if you have $ followed by a letter it will be interpreted as a variable name and interpolated.

Link to comment
https://forums.phpfreaks.com/topic/260152-printing-a-script/#findComment-1333390
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.