PHP – What Is It Good For?

So, interested in using PHP for your website? You are making a smart move. PHP is great for a relatively small and simple website like mine (say between 10 and 100 pages) and offers easy implementation of:

  1. Including template files. This allows you to have one file that you can pull in on your site at anytime in any place. A simple and common implementation of this is to write one file that includes the header, and another file for the footer. I use this on my own site.
  2. Storing data in array files. This is a great way of displaying different content on a simple template page. For example, on my site, I have one file that lays out what the page will look like in my photography section, and then another file that has different content for different photographs. Only 2 files can create an endless number of pages!
  3. A simple and functional formmail script. This can allow users and/or customers to fill out a form, sending an email to a specified account. This helps your users easily get in touch with you.

It is important to realize what PHP actually does before you use it. PHP is a server side scripting language. That means that the code you write in your files are interpreted by the server before it reaches the user. This is different from client side scripting languages like Javascript where the code reaches the user, and is then implemented. Usually, the PHP will be read by the server, and it will output plain markup or HTML. This is great because it doesn’t rely on your users’ browsers to do anything. Some users turn off Javascript which can be a problem if you use javascript to include certain code in your files.

Soon, I’ll write a post on simple code to get started on some of these uses of PHP. If you’ve never coded anything other than HTML/CSS before, then PHP will be a much different step because it uses logic statements. However, if you’ve ever coded anything with logic (C+, Java, ASP.NET, Javascript, Visual Basic, etc.) then PHP won’t be that hard to pick up.

2 Responses to “PHP – What Is It Good For?”

  1. Sean says:

    Hi, I’m enjoying dipping into your blog – you write clearly & make sense! With regard to php & wordpress (I know css/html & jquery but little php), I’m finding it hard to find a tut I can easily follow on making a theme look exactly like my site for a blog page. I wonder if you’ve been in this position in the past or have any thoughts or advice?

  2. David says:

    Hey there. So glad that it has been of so much help to you, for both php, and for that sticky footer problem you had.

    As for your question about wordpress, you really have two options. You can install wordpress as a subdirectory of your website (/blog/ for example) or you can use wordpress as your CMS and install it in the root directory.

    Either way, you’ll want a theme for wordpress that is relatively simple in nature. After you have that installed, you want to go to the “Appearance” menu item on the left navigation, and under that, pick “Editor”. There, you’ll see a list of files that will allow you to manage the appearance of that theme. You’ll want the “header.php”, “footer.php”, and “style.css”. Don’t be intimidated by the php in the first two files. Just look for the html that gets outputted by the theme and work from there to redo whatever html layout you need to do. Be careful though, once you’ve changed a theme, you should either NEVER update it, or move it to a different folder so that it won’t get overwritten.

    If you have more questions, feel free to email me. This site is entirely hosted on wordpress and is obviously very customized (built off of a simple theme though).