I would like to know how I can preview a page that is saved as PHP in a web browser. Currently all that is displayed is the code in the browser.
| SitePoint Sponsor |





I would like to know how I can preview a page that is saved as PHP in a web browser. Currently all that is displayed is the code in the browser.



You have to install web server and PHP inorder to see the php working on browser.Try installing WAMP if you are using Windows or install LAMP.
http://php.iis.net/
IIS 5.1, Windows XP
IIS 6, Windows Server 2003
IIS 7, Windows Vista, Windows Server 2008
IIS 7.5*, Windows 7, Windows Server 2008 R2
* IIS 7.5 is the same as IIS 7 but with download-able extensions included in the package.
Another quick way to get PHP installed and running on Windows is to use, Microsoft Web Platform Installer 2.0 Beta.





All I have to do is install XAMP\WAMP\LAMP and I will be able to preview PHP files in the browser, oh that is good.



You have to install wamp and you can get the php code inside http://localhost





Alright I will do that, in hopes that it works out, thank you.





Alright, I installed XAMP when I preview in FF or IE I still see code. And I have apache installed, but not MySQL.



Its not preview.You have to copy and paste the php files into www of the folder.And start xamp.
then type : http://localhost
inside the browser.





I have to copy the PHP files into what folder ?



were did you install xamp ? xamp/www .
create a folder called test and after pasting the php files you can just goto browser and type : localhost/test





I created a sub-folder called test within the "XAMPP" folder then I typed
http://localhost/test
Object Not found!



did you see a www inside xamp folder ?
create test inside it and try


I use wampserver, available from http://www.wampserver.com/ , but if you cant get xamp working, you probably can't get wampserver working either.





There is a www sub directory within the PHP folder, so I tried that and it didn't work.
http://localhost/php/www/test




No. You place the files in [PATH TO XAMPP INSTALLATION]/htdocs/ directory and access them through http://localhost/.
Pawel Decowski (you should follow me on Twitter)








I don't understand it's not working for me. I placed the "test" directory in the /XAMPP/HTDOCS/test then I went to http://localhost/ and I don't see nothing I can't preview the file???




If you put the files in */htdocs/test/ then you access them via http://localhost/test/.
What do you mean by saying you see nothing? You must see something (directory listing or an error message).
EDIT: You may also want to check this thread on setting up development environment in XAMPP.
Pawel Decowski (you should follow me on Twitter)





I got it working using http://localhost/test but the only problem is the PHP page when viewed does not display how it should, for example if the text is styled "white" it's shown as "black" how come ?




You probably have absolute paths to CSS. If you reference CSS files as /css/styles.css then it looks for xampp/htdocs/css/styles.css rather than xampp/htdocs/test/css/styles.css because xampp/htdocs/ is document root.
Have a look at the link to a thread in my previous post. I explained in it how to set up virtual hosts in XAMPP.
Pawel Decowski (you should follow me on Twitter)





I have the CSS not external but embedded into the HTML so there is nothing to reference.




There's probably something else wrong (most likely with your CSS). You need to give more information.
Pawel Decowski (you should follow me on Twitter)





The page thus far is very simple, all I have is a <h1> tag colored white and a background of blue, the blue background shows up fine but the <h1> tag shows up not as white but as black, in the PHP page.
Edit
I fixed it, it was because I had made my <h1> tag as a <id> so I had to remove the pound symbol and all was fixed![]()
Bookmarks