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

PHP "compiles" comments?

P: n/a
I was working on some php code yesterday and one of the lines in it
was:

print "<?xml version=\"1.0\" ?>\n";

when I tried to run it I would get an unexpected $end on the last line
of the script. After a while of debugging the code, commenting out
lines etc I figured out the above line was causing the issue by
changing it to:

print "<?xml version=\"1.0\" ?".">\n";

and it worked.

The reason I mention compiles comments in the subject, is even with
the original line commented php was still giving the error. I finally
figured out it didn't like the ?next to each other, it was seeing it
as an end to the script, even though it was originally in a print line
and then later in a commented line.

Is this normal, that you have to always seperate ?when using it in
php no matter where it is?

Bill H
Aug 28 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
I'm not sure about the ?issue and php seeing it inside comments. Sounds
like a bug to me.

See if single quotes around the string works. It may be a better option to
use anyway:

print '<?xml version="1.0" ?>\n'; // with single string quotes, nothing
should be evaluated between the single quotes. Hopefully, the ?will not
be interpreted as a close script tag as before.

Also, as an aside, I understand echo instead of print in this context is
faster too.

so, echo '<?xml .... ';
"Bill H" <bi**@ts1000.uswrote in message
news:ab**********************************@c65g2000 hsa.googlegroups.com...
>I was working on some php code yesterday and one of the lines in it
was:

print "<?xml version=\"1.0\" ?>\n";

when I tried to run it I would get an unexpected $end on the last line
of the script. After a while of debugging the code, commenting out
lines etc I figured out the above line was causing the issue by
changing it to:

print "<?xml version=\"1.0\" ?".">\n";

and it worked.

The reason I mention compiles comments in the subject, is even with
the original line commented php was still giving the error. I finally
figured out it didn't like the ?next to each other, it was seeing it
as an end to the script, even though it was originally in a print line
and then later in a commented line.

Is this normal, that you have to always seperate ?when using it in
php no matter where it is?

Bill H

Aug 28 '08 #2

P: n/a
On 28 Aug, 22:01, "Joe Butler" <ffffh.no.s...@hotmail-spammers-
paradise.comwrote:
I'm not sure about the ?issue and php seeing it inside comments. *Sounds
like a bug to me.

See if single quotes around the string works. *It may be a better option to
use anyway:

print '<?xml version="1.0" ?>\n'; // with single string quotes, nothing
should be evaluated between the single quotes. *Hopefully, the ?will not
be interpreted as a close script tag as before.

Also, as an aside, I understand echo instead of print in this context is
faster too.
Please do not top post.
http://www.faqts.com/knowledge_base/...l/aid/1/fid/40
Aug 28 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.