An Introduction to PHP

If you are going to start using php, you really need to understand what it is. PHP is a server-side-scripting-language. What that means is that when your web browser requests a page that has php code in it, ALL of the code is processed at the server before you see the page. The basic function of php is to generate HTML for presentation in your browser, but that is not all. PHP can manipulate strings, send an email, fetch information from a database, utilize FTP for file transfers, manipulate files, and even manipulate images.

So, what all can you do with php? Well, check out the php documentation and you can get a really good idea. The documentation lists all of the core functions available with a php installation, along with functions available through included libraries such as php-mysql for interactivity with a MySQL database, or php-gd for image manipulation.

Be sure to check out the comments in the php function reference pages. There is a lot of example code to help you get started.

So, why not get your feet wet? One of the functions readily available in php is the date() function. Create a page and call it hello.php. You can type or copy the following code into it:

<?php
echo "<p>Hello. Today's date is ".date("F j, Y, g:i a")."</p>";
?>

Upload this to your web server and go to that address in your browser. Here is a working example.

You will see today’s date, and if you view the source code, simply plain HTML markup provided by php!

This is only the tip of the iceberg, as this is only one function out of hundreds. One good example of php is the blog software you are using right now to view this content - wordpress. Keep reading for more examples, more ideas and eventually we will use what we are learning (combined with other things like javascript) to create useful web applications.

Tags:

This entry was posted on Friday, May 1st, 2009 at 2:28 pm and is filed under PHP. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>