SitePoint Sponsor

User Tag List

Results 1 to 23 of 23
  1. #1
    Non-Member
    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.

  2. #2
    SitePoint Evangelist
    Join Date
    Jun 2007
    Posts
    487
    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.

  3. #3
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    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.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  4. #4
    Non-Member
    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.

  5. #5
    SitePoint Evangelist
    Join Date
    Jun 2007
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SiberianHuskey View Post
    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

  6. #6
    Non-Member
    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.

  7. #7
    Non-Member
    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.

  8. #8
    SitePoint Evangelist
    Join Date
    Jun 2007
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SiberianHuskey View Post
    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.

  9. #9
    Non-Member
    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 ?

  10. #10
    SitePoint Evangelist
    Join Date
    Jun 2007
    Posts
    487
    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

  11. #11
    Non-Member
    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!

  12. #12
    SitePoint Evangelist
    Join Date
    Jun 2007
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    did you see a www inside xamp folder ?

    create test inside it and try

  13. #13
    SitePoint Addict skunkbad's Avatar
    Join Date
    Apr 2008
    Location
    Temecula, CA
    Posts
    272
    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.

  14. #14
    Non-Member
    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

  15. #15
    Web Professional
    Join Date
    Oct 2008
    Location
    London
    Posts
    862
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SiberianHuskey View Post
    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/.

  16. #16
    SitePoint Evangelist
    Join Date
    Jun 2007
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SiberianHuskey View Post
    There is a www sub directory within the PHP folder, so I tried that and it didn't work.
    http://localhost/php/www/test
    Quote Originally Posted by decowski View Post
    No. You place the files in [PATH TO XAMPP INSTALLATION]/htdocs/ directory and access them through http://localhost/.
    Yeah decowski is right.I am sorry I was referring on wamp.

  17. #17
    Non-Member
    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???

  18. #18
    Web Professional
    Join Date
    Oct 2008
    Location
    London
    Posts
    862
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SiberianHuskey View Post
    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.

  19. #19
    Non-Member
    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 ?

  20. #20
    Web Professional
    Join Date
    Oct 2008
    Location
    London
    Posts
    862
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SiberianHuskey View Post
    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.

  21. #21
    Non-Member
    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.

  22. #22
    Web Professional
    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.

  23. #23
    Non-Member
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •