467,894 Members | 1,461 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,894 developers. It's quick & easy.

why does JS give runtime error?

I have included in my html code (SRC) a file that I want Javascript to
ignore, but PHP to execute (if parsed by PHP)

the js function is:
function justphp(f) {
$test="<?php die(); ?>";
return;
}

In javascript the variable $test is just a string and will never be used,
but in PHP it will die when executed.
whenever I read it as javascript though I get a runtime error:
Line 2: Error: Unterminated string constant.
PHP works fine.
But my string IS terminated! Why does it not just assign the string and
ignore it, like it is supposed to...
Or what am I missing?

Thanks for any comments you may have,

John.

(IE6, win98)
Jul 20 '05 #1
  • viewed: 2062
Share:
1 Reply
"JohnS" <Pl**********@myaccount.com> writes:
I have included in my html code (SRC) a file that I want Javascript to
ignore, but PHP to execute (if parsed by PHP)

the js function is:
function justphp(f) {
$test="<?php die(); ?>";
return;
}

In javascript the variable $test is just a string and will never be used,
but in PHP it will die when executed.
The PHP is executed on the server, long before the javascript is
executed on the client. If the "die" function stops PHP execution,
then I bet the rest of the page from there is never sent to the browser,
including the end quote.
whenever I read it as javascript though I get a runtime error:
Line 2: Error: Unterminated string constant.
PHP works fine.
But my string IS terminated! Why does it not just assign the string and
ignore it, like it is supposed to...
Or what am I missing?


What is the code that is sent to the browser? I bet the answer is in
there, since that is the code that contains the error.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

13 posts views Thread by Jason Huang | last post: by
2 posts views Thread by Pavils Jurjans | last post: by
14 posts views Thread by Anoop | last post: by
52 posts views Thread by Ben Voigt [C++ MVP] | last post: by
1 post views Thread by jabbari | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.