String after // is causing script to bomb

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

    #1

    String after // is causing script to bomb

    Hi All,

    I have the following comment in one of my lines of code:

    // a processing instruction like <?php return "Hello, world!"; ?> somewhere
    in the XML would cause the

    Now, when I try and execute the script, I get a parse error referencing the
    line on which that comment occurs. Taking out the part that reads "<?php
    return Hello World;" ?> makes the parse error go away.

    Using /* */ style comments also eliminates the error.

    Is this a bug? Should not everything after // be ignored by the parser?

    FYI, here is the error:

    Parse error: parse error, expecting `T_OLD_FUNCTION ' or `T_FUNCTION' or
    `T_VAR' or `'}'' in <filename> on line 130

    -Josh


  • Pedro

    #2
    Re: String after // is causing script to bomb

    Joshua Beall wrote:[color=blue]
    > Hi All,
    >
    > I have the following comment in one of my lines of code:
    >
    > // a processing instruction like <?php return "Hello, world!"; ?> somewhere
    > in the XML would cause the
    >
    > Now, when I try and execute the script, I get a parse error referencing the
    > line on which that comment occurs. [...][/color]



    <quote>
    The "one-line" comment styles actually only comment to the end of
    the line or the current block of PHP code, whichever comes first."
    </quote>


    so ... the line
    $a = $b; // never forget the <?php and ?> tags in your source

    is parsed as
    $a = $b;
    tags in your source

    which, of course, generates a parse error at "tags in your source"


    --
    I have a spam filter working.
    To mail me include "urkxvq" (with or without the quotes)
    in the subject line, or your mail will be ruthlessly discarded.

    Comment

    • Pedro

      #3
      Re: String after // is causing script to bomb

      I wrote:[color=blue]
      > http://www.php.net/manual/en/languag...x.comments.php
      >
      ><quote>
      > The "one-line" comment styles actually only comment to the end of
      > the line or the current block of PHP code, whichever comes first."
      ></quote>
      >[/color]
      [and a bunch of php code that shouldn't be here]

      The problem is with the XML, not php:


      this XML/PHP data
      --------
      <!-- can't remember exact syntax -->
      <xml version="1.0">
      <doctype something>
      <data>
      <record id="1">
      <?php
      echo '<name>Pedro</name>'; // use of <?php ... ?> in XML is ok
      ?>
      </record>
      </data>



      is received by the client as
      --------
      <!-- can't remember exact syntax -->
      <xml version="1.0">
      <doctype something>
      <data>
      <record id="1">
      <name>Pedro</name> in XML is ok
      ?>
      </record>
      </data>

      --
      I have a spam filter working.
      To mail me include "urkxvq" (with or without the quotes)
      in the subject line, or your mail will be ruthlessly discarded.

      Comment

      • Alvaro G Vicario

        #4
        Re: String after // is causing script to bomb

        *** Joshua Beall wrote/escribió (Fri, 31 Oct 2003 00:09:56 GMT):[color=blue]
        > Is this a bug? Should not everything after // be ignored by the parser?[/color]

        No:

        "The one-line comment styles actually only comment to the end of the line
        or the current block of PHP code, whichever comes first. This means that
        HTML code after // ?> WILL be printed: ?> skips out of the PHP mode and
        returns to HTML mode, and // cannot influence that."



        --
        --
        -- Álvaro G. Vicario - Burgos, Spain
        --

        Comment

        Working...