Extra characters after echo in php
Getting started in PHP, but even with a "Hello world" I'm running into problems ...
Here's my page:
<html>
<body>
<?php
echo "<p>Hello world.<br /> </p>" ;
?>
</body>
</html>
But instead of just 'Hello world.' I get
Hello world.
" ; ?>
What 开发者_高级运维gives?
FWIW, I'm using XAMPPlite (which is an Apache 2.5.8 with a PHP 5.3.1 on Win XP).
You should save the file with a .php extension, not as .html.
it is not parsing it as php, it is just outputting it as html i.e. it treats
<?php
echo "<p>
as an (unknown) tag.
That's pretty odd..
Did you try taking the space out before the semicolon?
There is absolutely nothing wrong with your code, I'd look for the problems elsewhere. Is the server running/configured correctly, is Apache configured for php, (is your file extention php?).
It's because the script only gets processed in a web server before sending the output to a browser. You must be trying to run it on the client side, try putting it into a web folder on a web server. You're code has nothing wrong.
精彩评论