PHP Tutorial - PHP md5() Function






Definition

The md5() function produces a data checksum in 32-bytes. "MD" stands for Message Digest.

Syntax

PHP md5() Function has the following syntax.

string md5 ( string str [, bool raw_output] )

Parameter

Parameter Is Required Description
string Required. The string to be calculated
raw Optional. Hex or binary output format:

Possible values for raw.

  • TRUE - Raw 16 character binary format
  • FALSE - Default. 32 character hex number




Return

PHP md5() Function returns the string for the checksum.

Example

Get the checksum for a string


<?PHP
$md5hash = md5("java2s.com"); 
print $md5hash; 
?>

The code above generates the following result.