Jump to content

echo newline in source


wannabe_god

Recommended Posts

I tried to combine javascript and php, and some one lines js commands work wellecho("<script>alert(\"test\")</script>");but now I have larger javascripts, and when I echo all the commands he doesn't work anymore ("error on the page" and he just doesnt works), and it is too hard to check the html output of the php script to check whats wrong, 'couse the echoëd code has no newlines in the source.... Could someone please help me out :)

Link to comment
Share on other sites

Can you use <?php ?> in your code to separate the PHP from the javascript? Something like this:

<html>  <head>    <script type="text/javascript">function myfunction(){    // normal javascript functionality to go here...}    </script>  </head>  <body><?php    // PHP functionality to go here...?>  </body></html>

Link to comment
Share on other sites

@sigh: i want to echo the javascript with php, not separate them :)@aspnetguy: like<?phpecho("<script>" . \n);echo("<alert(\"hey\")" . \n);echo("</script>" . \n);?>i suppose?
nope like this
<?phpecho('<script>\n');echo('alert("hey")\n');echo('</script>\n');?>

note: using single quotes lets you use double quotes inside without escaping them.

Link to comment
Share on other sites

Ive never seen that anywhere and in my php refrence book, by Mr. O`reilly it says to use that and never mentions script, and he put everything in that. Except half of the 2,500 functions :), I will research it (provide a link plz?)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...