Here is my html with a php script:
<html> <head> <title>Bob's Auto Parts</title> </head> <body> <h1>Bob's Auto Parts</h1> <table width = 100% > <tr> <?php echo "<td>This is working.</td>"; ?> </tr> </table> </body> </html>
Why is the output of this appearing with a ; ?>. I want it to be 'This is working.' only. Here is the ouput
Bob's Auto Parts
Bob's Auto Parts
This is working."; ?>
I know I am doing something wrong here but not able to figure it out. Thanks in advance.
You cannot have PHP echo more PHP code to be evaluated because PHP interprets your code in a single pass.
Description ¶ echo(string ...$expressions ): void. Outputs one or more expressions, with no additional newlines or spaces. echo is not a function but a language construct. Its arguments are a list of expressions following the echo keyword, separated by commas, and not delimited by parentheses.
Make sure that you are using <?php
and not <?
shorthand since that may be disabled on your server. This will cause the output of "; ?> as it happened to me a few months ago in a transition to PHP5.
I've only seen the odd output like this when the PHP parser isn't detecting it as PHP. Make sure to check that PHP is functioning as expected and that the <?php
tag is being recognized.
Any of these (or more) could be your answer why it is not working
.php
?http://localhost/myfile.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With