How to test if your server supports / is running PHP.

Written by on June 15, 2010 in Coding - 3 Comments
php-test

If you’re going to use PHP on a website the server needs to be running PHP right? Well duuh! If you work on a variety of websites for a lot of clients, you’re going to deal with different hosts and servers. Before you hook up a form to PHP or whatever else you are planning on doing, you better make sure the server can run PHP if it isn’t.

The quickest way to test servers for PHP is to create a testing PHP file that you can upload to a clients website to see if PHP is running. The good thing about this is you can reuse it for every site. You simply upload this to the server, and try to open it in your web browser. If it works, you’ll see an html page with the info about the PHP running on the server. If it isn’t running PHP, well you won’t see anything!

Keep reading for the code to make your own. I also provide mine as a download to save you time.

If you want to create your own, just create a document called info.php. Within this file paste the following text:

<?php
phpinfo();
?>

Once you upload that, try to open it in your browser. If it works, it’ll show the info about the PHP running on the server. If it doesn’t work…well you better call the host.

Speaking of hosts, here’s the host I recommend to all my clients, and use for all of my personal websites, including WebDesignAndSuch.com and BeantownDesign.com

Anyway, back to the PHP topic, here is a info.php file like I mentioned above. Figured I’d save you some time. Happy coding!

Download info.php

About the Author

Mike Ilsley "ilz" is a Boston based website designer, front-end developer, WordPress addict, owner of Beantown Design, and exclusive ThemeForest author. Check him out on Twitter, Facebook, Google+ and don't forget to subscribe to the WebDesign&Such email RSS feed. Also, check out his latest project, jQueryMobileShowcase.com.

  • http://www.meltdowntech.com Ben Everard

    Hi, just surfed in from Twitter (I’m @ilmv).

    I’ve got two problems with this post, the first is that PHP has nothing to do with the users browser, as PHP is a server side language it’s the server your trying to test.

    And whilst it’s awesome that you’ve shared this great little function, you probably want to remove the demo, it’s generally accepted that you never show a live php_info() of your server to your visitors… it’s a very easy way for possible hackers to size up your server and find holes to jump through.

    Have fun :-) , Ben

  • ilz

    Thanks for the heads up Ben, good point about the demo, it is removed. And I don’t know why I wrote “browser”.. brain meltdown I guess!

  • http://www.benefitsofgreen-tea.com/ benefits of green tea

    Would you be excited about exchanging hyperlinks?