why does JS give runtime error?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JohnS

    #1

    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)


  • Lasse Reichstein Nielsen

    #2
    Re: why does JS give runtime error?

    "JohnS" <PleaseNoSpam@m yaccount.com> writes:
    [color=blue]
    > 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.[/color]

    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.
    [color=blue]
    > 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?[/color]

    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 - lrn@hotpop.com
    Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
    'Faith without judgement merely degrades the spirit divine.'

    Comment

    Working...