By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,053 Members | 1,209 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,053 IT Pros & Developers. It's quick & easy.

String after // is causing script to bomb

P: n/a
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
Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Joshua Beall wrote:
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. [...]


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>
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.
Jul 17 '05 #2

P: n/a
I wrote:
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>

[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.
Jul 17 '05 #3

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


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."

http://us2.php.net/manual/en/languag...x.comments.php

--
--
-- Álvaro G. Vicario - Burgos, Spain
--
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.