5

Possible Duplicate:
PHP code is not being executed (i can see it on source code of page)
web browser not processing PHP code as PHP code

I have installed XAMPP on my computer which is Windows 8 pro. I use to work with Windows 7 every time I run the index.php file on Windows 8 it shows the code on the browser IE10.

Here is what I have done:

  1. I have named the file correctly: index.php
  2. I have installed the server and saved the files inside c:/xampp/htdocs/PHP/
  3. I have used <?php ?> to open and close all PHP tags and everything else seems working fine, like, PHPMyAdmin, and the php.ini file

I don't know whats wrong and it is driving me crazy ...

Farris

Community
  • 1
  • 1
FarrisFahad
  • 356
  • 1
  • 4
  • 17
  • 2
    is the url `http://localhost ... index.php` and NOT `file:/// ...`?? –  Nov 05 '12 at 22:59
  • Are you using short php tags? Like `` ? If you are that could cause problems. – smottt Nov 05 '12 at 22:59
  • @Dagon when I open the file the location is file:///C:// not localhost/ – FarrisFahad Nov 05 '12 at 23:01
  • 3
    well that's the problem. your reading the 'raw' file with the browser, you need to parse it through the webserver (with php). type (copy paste) `http://localhost/index.php` or maybe its `http://localhost/PHP/index.php` in the browser –  Nov 05 '12 at 23:02
  • @smottt I am using the full – FarrisFahad Nov 05 '12 at 23:03
  • and many other duplicates, https://www.google.com/search?q=site:stackoverflow.com+php%20browser%20shows%20php%20code,%20doesn't%20run – mario Nov 05 '12 at 23:06
  • @Dagon how can I parse it through the webserver with PHP? – FarrisFahad Nov 05 '12 at 23:06

1 Answers1

16

The problem is you're not parsing the file via the web server, but accessing it directly.

you need to use the url:

http://localhost/index.php 

or maybe (based on your path above) its

http://localhost/PHP/index.php

in the browser

  • usually trought httpd.conf can configure all needed directories to be accessible via browser. By default it's only one document root which will execute PHP code – DTukans Nov 05 '12 at 23:08
  • yup, but lets get the basics working first ;-) –  Nov 05 '12 at 23:09