Reputation: 43
Here's the thing.. I have a file named first.php containing the following code:
<html>
<title>trial</title>
<head>welcome</head>
<body>
<br>
<?php
echo "hello world";
?>
</body>
</html>
However when I execute it, the php code is not interpreted. The short open tag also seems to be on. I'm using wampserver. what have I missed?
Upvotes: 1
Views: 8954
Reputation: 1677
The Tag must be inside the Tag
<head>
<title>trial</title>
</head>
<body>
<?php echo "hello world"; ?>
</body>
Upvotes: 0
Reputation: 21
.php
file(s) under a directory say "myfirst" under /wamp/www
wamp icon > PHP > PHP Settings > short open tags
. Make sure it is checked.localhost/myfirst/first.php
hopefully it works
Upvotes: 1
Reputation: 2169
<html>
<head>
<title>trial</title>
</head>
<body>
<?php echo "hello world"; ?>
</body>
</html>
Try it with the title wrapped inside the head like it should be. The welcome was just floating around in no mans land, may have broken your code. Also, use a doctype tag - < !html>
without the space is HTML5.
Update Add this to a blank php file in your localhost folder.
<?php
// Show all information, defaults to INFO_ALL
phpinfo();
?>
If you don't get a report back, it's a server config problem.
Also make sure your putting it in htdocs
or whatever your "public" folder is.
Upvotes: 0
Reputation: 94642
Make the changes suggested by @kcdwayne.
Now run the code from your browser, DONT doubleclick on your php file from explorer, it has to run through a browser.
Upvotes: 0
Reputation: 719
It seems your server is misconfigured. Your apache server must recognize .php files as a php application and evaluate the code.
AddHandler application/x-httpd-php .php
See if you find the line above in your http.conf file.
Upvotes: 2