PHP Lesson 5 - PHP Functions

One of the reasons that PHP is so popular stems from it’s powerful and varied functions. There are literally hundreds of useful functions that PHP can perform for your website. We’ll cover the most popular functions and the functions that can be commonly used in basic websites.

Typically, you will see general PHP information at the top of most PHP scripts. There is an easy way to display this information without having to enter it all in. For example:

This will display the php.ini location, web server, config line, system information and more general info.

You have many options from INFO_CREDITS, which displays all the credits for PHP4, INFO_MODULES, which will display all of the loaded modules, INFO_LICENSE, which displays the PHP license information and much more. If you don’t want to enter in all of these functions separately, you can call them up by inserting INFO_ALL in the script above instead of INFOR_GENERAL. That will display all of the general PHP info at the top of your script, but not on the page itself. This is most commonly used by developers to help users of a script debug, test or get more information on the script itself.

There are also functions designed for server variables, such as Referrer, Browsers and IP address tools. This can be used to display information on where your users are visiting before they come to your site and for a variety of different applications. For example:

This script will report to you how your user found your site and which browser they were using to view your pages.

Other popular functions are:

cal_days_in_month which will return information on the number of days in any given month for a specified time frame to the browser.

ccvs_add which will add data to a transaction. Very useful for ecommerce applications.

pdf_save – will save the current document as a pdf file.

print – will automatically print a desired page.

realpath – displays the absolute path to a file in the browser.

These are just a few of the many useful functions PHP can perform. You can visit http://www.php.net for a complete list of functions that you can use with PHP.

Our next article will cover PHP Loops, which are incredibly useful commands that you can use in PHP. These loops can save you hours of programming time and automate tasks to help you with your website development and creation. Don’t forget to experiment with your own variables and try out some various functions just for fun. You’ll be surprised with all that you can do with PHP.

Related Posts:
Java Script Lesson 4 - Functions
Java Script Lesson 6 - Functions With Two Arguments
Java Script Lesson 5 - More Functions
Java Script Lesson 3 - Arrays
Java Script Lesson 8 ‘ Using More Than One JavaScript on a Page

Posted on 12/27/05 2:23 AM

Be the first to comment!

Leave a Reply


SYNDICATION

    NEW! Blog Feed:
    Reviews Feed:
    News Feed:
    Resources Feed: