TMan
TMan

Reputation: 4090

local php files will not work

I have to do a php project. I done php before so I understand the syntax for the most part. Just for a test, I made a file.php and in it I wrote:

   <html>

   <body>

   <?php echo "helloWorld"; ?>

   </body>

   </html>

Well it won't display. The screen is blank. I tried it in chrome, firefox, IE and nothing wants to dispaly. Actually in IE, the source is displayed which is wierd. I also tried it without all the html and just used xampp to render it. It will not work. If I right click tho in the browser and view source, the code is there. Any ideas on what's going on?

Upvotes: 0

Views: 207

Answers (2)

Mattisdada
Mattisdada

Reputation: 914

If you're new to setting up your own server, i would recommend using XAMPP (or WAMP), these are preconfigured PHP, Apache and MySQL servers.

If you're sure you have setup your server correctly check the following:

  1. Make sure your executing your files from the server directory and NOT from a local directory. (your URL should look something like "http://localhost/test.php") Note: You will need to phisically store the files in a place the apache server will look for, an example from XAMPP (on Windows, as thats what im assuming your using) is: "C:\xampp\htdocs"

  2. Make sure your file ends in .php or something else that the Apache server will pickup as a PHP file. (.php3, .php4, etc)(make sure you didn't accidentally leave a .txt or something like that at the very end)

  3. Check mod-php module is enabled (as Julien mentioned)

Hope that helps!

Edit: Try

<?php
    phpinfo();
?>

That as well, it should give you the php configuration information if the server is setup correctly.

EDIT2: I see that you are using XAMPP, double check that the following file exists at the very least: "C:\xampp\apache\conf\extra\httpd-xampp.conf", it loads the PHP module

Upvotes: 3

Julien Bourdon
Julien Bourdon

Reputation: 1723

Well, it comes from your web server configuration. If you're using Apache, have you enabled the mod-php module?

Upvotes: 5

Related Questions