1. Computing & Technology

PHP Functions

In PHP a function is a predefined set of commands that are carried out when the function is called. In addition to being able to write your own functions, PHP has a number of predefine functions for you to use. Below are many functions we discuss in our various tutorials, with simple definitions and examples to follow.

Eval () PHP Function

How to evaluate the inputed text string as PHP using the eval function

IF - Using IF in PHP

IF - We use if in PHP to make a decision

Atan2 () PHP Function

How to calculate the arc tangent of two coordinates in radians using PHP

GoTo

How tutorial of how to use GoTo in PHP to skip over code.

<Script> Tags

How to use PHP in a file that supports mixed scripting languages using the <script> tags

Abs () PHP Function

How to use the ABS () function in PHP to return the absolute value of a number

Acos () PHP Function

How to use the acos function to return the arccosine of a number using PHP.

Addslashes () PHP Function

Addslashes adds back slashes into your form data

Array () PHP Function

Array () PHP Function

Asin () PHP Function

How to find the arcsine (asin) of a number using PHP.

Atan () PHP Function

This PHP function allows you to find the arctangent of a value in radians.

Base_convert () PHP Function

Converting one number base to another using PHP

Bindec () PHP Function

The bindec function is used to convert a binary string to a decimal in PHP.

Cal_days_in_month () PHP Function

This PHP function tells you how many days are in a given month in a given year.

Ceil () PHP Function

Always rounding a number up to the nearest whole number

Cos () PHP Function

How to calculate the cosine of a number, in radians, using PHP.

Cosh () PHP Function

How to use the Cosh function in PHP to find the hyperbolic cosine

Crypt () PHP Function

The crypt () function encrypts data in PHP

Date () PHP Function

Use date to format the time () function's output.

Decbin () PHP Function

The Decbin PHP Function is used to convert a decimal into a binary number.

Dechex () PHP Function

The dechex function is used to convert a decimal number into a hexadecimal number.

Decoct () PHP Function

The Decoct PHP Function is used to convert a decimal into an octal number

Easter_date () PHP Function

PHP function that calculates what day Easter Sunday falls on in any given year.

Echo () PHP Function

Echo () PHP Function

Else () PHP Function

Else () is used to give an alternate set of code to execute when the if () part of a statement is false.

Elseif () PHP Function

Elseif () is used in conditional statements to make choices.

Eval () PHP Function

Eval () is used to evaluate its input string as PHP code

Exp () PHP Function

The Exp () PHP Function is used to calculate e raised to the power of x.

Feof () PHP Function

The FEOF PHP function is used to test for the end of the file.

Fgets () PHP Function

Fgets is a PHP function that gets data from an external file line by line.

File () PHP Function

File () pulls data from an outside file and puts it into an array .

File_Get_Contents () PHP Function

File_get_contents reads the data from a file and returns it to the PHP file as a string

Floor () PHP Function

Always rounding a number down to the nearest whole number

Fopen () PHP Function

Use fopen() to open a file from php

For () PHP Function

For () is a form of loop in PHP

Foreach () PHP Function

Foreach () is a form of loop in PHP

Fread () PHP Function

Fread is a php function used to read the contents of a file and report the data back to the php file.

Fwrite () PHP Function

fwrite is a binary safe file write used to write to a file in PHP

Getenv () PHP Function

Free tutorial about how to use the getenv() command in PHP to get such things as the document root, or the user's IP address.

Get_magic_quotes_gpc () PHP Function

Checks if Magic Quotes is turned on or off in your php configuration

Hexdec () PHP Function

The Hexdec () PHP Function is used to convert a hexadecimal into a decimal number

Htmlspecialchars () PHP Function

Htmlspecialchars is used to convert special characters to HTML entities

Hypot () PHP Function

How to calculate the Hypotenuse of a right triangle using PHP and the hypot function

If () PHP Function

If () is used as a conditional statement in PHP

ImageColorAllocate () PHP Function

The ImageColorAllocate () function is used in PHP to set the color for an image you are creating.

Imagecreate () PHP Function

The imagecreate () function is used in PHP to create a new palette based image

Imagecreatetruecolor () PHP Function

The imagecreatetruecolor () function is used in PHP to create a new true color image

Imageellipse () PHP Function

Used to draw an ellipse in PHP using the GD Library

Imagefilledarc () PHP Function

Used to draw arcs or pie graphs in PHP using the GD Library

ImageLine () PHP Function

Used to draw a line in PHP using the GD Library

Imagepolygon () PHP Function

How to draw a polygon in PHP using the imagepolygon function and assigning the coordinates of each corner

Imagerotate () PHP Function

How to rotate an image using PHP with the GD Library

Imagestring () PHP Function

Image String is used to add a string (text) to an image

Include () PHP Function

Include external files within a PHP file

Is_Binary () PHP Function

This Is_Binary function in PHP is used to check if the input is a binary number.

Is_Numeric () PHP Function

The PHP function is_numeric is used to check if a variable is a number.

Is_string () PHP Function

The is_string php function is used to check if the value is a string. It will return true or false.

Mail () PHP Function

Sending email from PHP with mail ()

Max () PHP Function

The Max () php function returns the largest number in an array or group of numbers

Min () PHP Function

The Min () php function returns the lowest number in an array or group of numbers

Mktime () PHP Function

Mktime is used to get the timestamp for a specific date

Mysql_close () PHP Function

How to close a MySQL Connection from a PHP file

Mysql_connect() PHP Function

How to connect to your MySQL database from a PHP document

Mysql_error () PHP Function

Report an error into PHP from MySQL when your SQL code encounters problems

Number_format () PHP Function

Format the decimal and 1000 separators, as well as the number of decimals places in a number

Octdec () PHP Function

The Octdec PHP Function is used to convert from an octal number to a decimal

PHP Log () Function

How to use the PHP Log function to find the natural logarithm.

PHPinfo () PHP Function

Learn more about the version of PHP your server is running using the php info command to see your version, path, and specific settings.

Pi () PHP Function

How to use the PI () PHP function as well as M_PI, M_PI_2, M_PI_4, M_1_PI, M_2_PI, M_SQRTPI, M_2_SQRTPI in your PHP code

Pow () PHP Function

How to use exponents in PHP to raise a number to the power of another number.

Preg_grep () PHP Function

Using Preg_grep to search an array and return an array

Preg_match () PHP Function

Searching a string and returning a true or false with preg_match

Preg_match_all () PHP Function

Searching an entire string for specified terms, and outputting to an array

Preg_replace () PHP Function

Performing a find and replace on a string or an array.

Preg_split () PHP Function

Splitting a string into an array based on your specifications

Print () PHP Function

Print () PHP Function

Print_r () PHP Function

Print_R is used to return an array in a human readable form in PHP

Rad2Deg () PHP Function

The Rad2Deg PHP Function is used to convert an angle measured in radians to one measured in degrees.

Rand () PHP Function

Generating a random number in PHP with the rand () function

Require () PHP Function

Include external files within a PHP file

Round () PHP Function

Rounding a number to a specified amount of decimals

Session_destroy () PHP Function

Session_destroy () is used to destroy all the data in a current session

Session_set_cookie_params () PHP Function

Session_set_cookie_params () is used to set the duration of a session cookie, as well as other optional cookie information

Session_start() PHP Function

The session_start() function is used at the beginning of all PHP pages utilizing sessions.

Session_unset () PHP Function

Session_unset() is used to clear all the variables in a session

Setcookie () PHP Function

A cookie is used to store information about a user on their computer

Sin () PHP Function

How to use the sine (sin) function to do mathematics in PHP

Sinh () PHP Function

How to use the Sinh PHP Function to determine the hyperbolic sine in PHP

Sqrt () PHP Function

Sqrt () PHP Function

Stripslashes () PHP Function

Stripslashes is used to remove blackslashes from data in php

Str_replace () PHP Function

Str_replace is used to find and replace parts of a string in PHP

Substr () PHP Function

How to use the Stbstr PHP Function to return part of a string in PHP

Switch () PHP Function

The PHP switch () function is used in replace of multiple if or elseif statements.

Tan () PHP Function

How to use the tangent (tan) function to do mathematics in PHP

Tanh () PHP Function

The Tanh PHP Function is used to find the hyperbolic tangent of the imputed number.

Time () PHP Function

Accessing the server time and formatting it

Uniqid () PHP Function

PHP code to generate a random unique user ID

Unset () PHP Function

Unset is used to destroy specified variables in PHP

While () PHP Function

While () is a form of loop in PHP

All PHP Functions

Learn all available PHP functions and what use each of them does in PHP.

Variations of Pi

The different mathematical variations of PI built into PHP.

Discuss in my forum

©2012 About.com. All rights reserved.

A part of The New York Times Company.