Reputation: 113
I'm working with PHP and HTML, but I have an issue popping up whenever I write some PHP code. An example of this is as follows:
<?php
echo "<h2>Hello?</h2>";
$var = 5;
echo "You have $var minutes to go.";
?>
What this ends up outputting on screen is:
Hello?"; $var = 5; echo "You have $var minutes to go."; ?>
But what I want to happen is this: Hello? You have 5 minutes to go.
Is there something I'm forgetting to do? It doesn't seem to matter whether or not I add the HTML preamble, or if I put a tag like
around the second echo line. Does anyone have any advice?
EDIT: Apparently I have failed to parse PHP correctly. This computer is new and I have XAMPP installed on it, but nothing else. Did I miss something I needed in order to use PHP?
Upvotes: 2
Views: 101
Reputation: 20737
The PHP isn't being parsed properly.
file:///C:/wamp/www/index.php
then that is incorrect.Upvotes: 2
Reputation: 3033
make php and html different.so things become much easier. try like this:
<h2>Hello?</h2>
<?php
$var = 5;
?>
You have <?php echo $var;?> minutes to go.
Upvotes: 0
Reputation: 23777
That sounds like if the php code wasn't interpreted.
Make sure to have the code in a file with a filename ending with .php
and that PHP is installed/enabled on your server.
Upvotes: 6