SitePoint Sponsor |
|
User Tag List
Results 1 to 23 of 23
Thread: Preview PHP code in a Browser?
-
May 10, 2009, 20:57 #1
- Join Date
- Jan 2008
- Location
- N43° 44.4824', W079° 13.9408
- Posts
- 2,220
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Preview PHP code in a Browser?
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.
-
May 10, 2009, 21:05 #2
- Join Date
- Jun 2007
- Posts
- 496
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
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.
-
May 10, 2009, 21:18 #3
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.
-
May 10, 2009, 21:25 #4
- Join Date
- Jan 2008
- Location
- N43° 44.4824', W079° 13.9408
- Posts
- 2,220
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
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.
-
May 10, 2009, 22:45 #5
- Join Date
- Jun 2007
- Posts
- 496
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You have to install wamp and you can get the php code inside http://localhost
-
May 11, 2009, 06:33 #6
- Join Date
- Jan 2008
- Location
- N43° 44.4824', W079° 13.9408
- Posts
- 2,220
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Alright I will do that, in hopes that it works out, thank you.
-
May 11, 2009, 09:43 #7
- Join Date
- Jan 2008
- Location
- N43° 44.4824', W079° 13.9408
- Posts
- 2,220
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Alright, I installed XAMP when I preview in FF or IE I still see code. And I have apache installed, but not MySQL.
-
May 11, 2009, 10:01 #8
- Join Date
- Jun 2007
- Posts
- 496
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
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.
-
May 11, 2009, 10:27 #9
- Join Date
- Jan 2008
- Location
- N43° 44.4824', W079° 13.9408
- Posts
- 2,220
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I have to copy the PHP files into what folder ?
-
May 11, 2009, 10:34 #10
- Join Date
- Jun 2007
- Posts
- 496
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
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
-
May 11, 2009, 10:39 #11
- Join Date
- Jan 2008
- Location
- N43° 44.4824', W079° 13.9408
- Posts
- 2,220
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I created a sub-folder called test within the "XAMPP" folder then I typed
http://localhost/test
Object Not found!
-
May 11, 2009, 19:20 #12
- Join Date
- Jun 2007
- Posts
- 496
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
did you see a www inside xamp folder ?
create test inside it and try
-
May 11, 2009, 21:45 #13
- Join Date
- Apr 2008
- Location
- Temecula, CA
- Posts
- 278
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I use wampserver, available from http://www.wampserver.com/ , but if you cant get xamp working, you probably can't get wampserver working either.
-
May 12, 2009, 08:16 #14
- Join Date
- Jan 2008
- Location
- N43° 44.4824', W079° 13.9408
- Posts
- 2,220
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
There is a www sub directory within the PHP folder, so I tried that and it didn't work.
http://localhost/php/www/test
-
May 12, 2009, 09:47 #15
- Join Date
- Oct 2008
- Location
- London
- Posts
- 862
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
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)
-
May 12, 2009, 10:48 #16
- Join Date
- Jun 2007
- Posts
- 496
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
-
May 12, 2009, 18:51 #17
- Join Date
- Jan 2008
- Location
- N43° 44.4824', W079° 13.9408
- Posts
- 2,220
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
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???
-
May 13, 2009, 02:19 #18
- Join Date
- Oct 2008
- Location
- London
- Posts
- 862
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
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)
-
May 13, 2009, 06:54 #19
- Join Date
- Jan 2008
- Location
- N43° 44.4824', W079° 13.9408
- Posts
- 2,220
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
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 ?
-
May 13, 2009, 06:59 #20
- Join Date
- Oct 2008
- Location
- London
- Posts
- 862
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
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)
-
May 13, 2009, 07:04 #21
- Join Date
- Jan 2008
- Location
- N43° 44.4824', W079° 13.9408
- Posts
- 2,220
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I have the CSS not external but embedded into the HTML so there is nothing to reference.
-
May 13, 2009, 07:16 #22
- Join Date
- Oct 2008
- Location
- London
- Posts
- 862
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
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)
-
May 13, 2009, 07:22 #23
- Join Date
- Jan 2008
- Location
- N43° 44.4824', W079° 13.9408
- Posts
- 2,220
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
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