Categories


What is PHP?

When first released in 1995, PHP was the official acronym for ‘Personal Home Page’.  However, as it became more popular,  and as its capabilities grew, PHP more commonly came to mean PHP: Hypertext Preprocessor –  simply put, PHP is a language that handles data before it becomes HTML. You might say, PHP is an HTML embedded scripting language, meaning PHP can be written within your document’s HTML code. And, with HTML being the code used for building all web pages, if you can hand code HTML, you’ll find PHP is only slightly more complicated.

For example: You have an HTML page that contains a form requiring a calculation. This page will end in the extension .html. In addition to having the HTML form, you’ll need a second page containing the PHP script defining the task to be performed. This page will have the extension .php. The name used for the document containing the PHP script will need to be included in the HTML form document so the server will know what action to take regarding the information that has been input and then what to do with the output as shown in the sample below.

In this snippet of code from the .html page containing the form, the server is directed to take the action as defined in the ‘handle_calcT22.php’ script and then ‘post‘ the results.

Scripting vs. Programming

Using PHP as a scripting language means it is designed to do something, i.e., perform a calculation; however, only after an action is taken – e.g., a user submits a form. On the other hand, programming is used to write stand alone applications. Some programs used for programming – although we won’t cover them here – are Java, C and Perl.

Another thing to know about PHP is that everything it does occurs on the server – not on the viewer’s computer.  To the contrary, JavaScript – one of the more popular scripting languages – has the event or action occurring in the web browser . . . also referred to as client-side.

One of the benefits of using PHP is that it can be used on servers running Windows, Macintosh, Unix as well as some other operating systems. Not only can PHP run on most operating systems, but also can be switched from one platform to another with limited or no modifications.

What PHP Can’t Do

Since PHP occurs server side, you cannot perform the following tasks:

  • Create a new browser window
  • Have pop-up alerts
  • Add mouse-overs
  • Resize the browser
  • Generate and alter forms
  • and more

None of these functions can be accomplished using PHP because the action occurs server-side and the actions above are client-side tasks.  [ Available through Javascripts. ]  So, why use PHP you ask?

The basic advantage of using PHP over HTML is that PHP makes your web pages more exciting – allowing you to customize them. For example, you could design your page to consider your visitor’s operating system or the time of day they visit. While you can customize your page to interact on a more personal level with your visitor, PHP can also interact with files and databases, handle  email, as well as many other things HTML cannot do.

Some of the basic tasks you can perform with PHP are

  • Create a Form
  • Perform Calculations
  • Create Arrays
  • Create Templates
  • Work with Date & Time
  • Send Email
  • Create Cookies

Conclusion

Just like with JavaScripts you don’t have to know how to write PHP scripts. There are a lot of free scripts on the Net available to download.  They can easily be used with a little configuration.   Two of our favorite free PHP scripts websites are

  1. http://www.hotscripts.com/
  2. http://phpform.net/

Want to see how PHP works?  Visit our website www.goldcoins-silverbullion.com  – “Online Tools” –  to see the  PHP scripts we created that allow our visitors to calculate the gold value of their karat weight jewelry right there online . . . and see what it’s worth before selling it.

Want to learn more about PHP? Get the easy to understand Visual Quickstart Guide by Larry Ullman – PHP for the World Wide Web from Amazon.  That’s our copy – you can see we use whatever is handy to mark our favorite places!


Comments are closed.