0

I am writing a few webpages and i want to use some php in one of them. The problem is that my php code never displays an ouput even of the simplist form.

I have this very basic code:

<html>
 <head></head>
 <body class="page_bg">
 Hello, today is <?php print("Hello"); ?>.
 </body>
 </html>

It doesnt display hello. I have other more complex webpages that just doesnt seem to do anything.
I am using win 7 and internet explorer 9 (or 10, not sure).
How do I fix this?

2
Contributors
5
Replies
19
Views
4 Years
Discussion Span
Last Post by MasterHacker110
0

This won't be a problem with your browser at all. It will likely either be the way in which you are running your file or a server configuration problem. Let me ask: Are you running this file on your machine directly by opening your file or are you running it through http://localhost/ ?

2

A number of problems then. You will need to have a web server set up your machine with PHP installed. Your files will need to be in the web root of that web server and finally by default .html files are not executed as PHP.

I'd recommend installing WAMP (If you're on windows), putting your files in "C:\wamp\www" (I think that's the webroot directory), chaning the extension to .php and running the files through putting http://localhost/filename.php in your browser (Or just http://localhost/ if your file is named index.php)

1

Currently all you are doing is opening your files with your browser which simply tries to render what it finds in there. Server side code has essentially nothing to do with your browser so it will not know what to do with PHP code. You need to get your browser to send requests to your webserver through following the steps above. Your web server will then process the files using PHP and return a response for your browser to render.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.