PHP md5() Function

P
PHP ltrim() Function
PHP md5_file() Function

What is the syntax of the MD5() function in php?

md5(string,raw)
ParameterDescription
stringRequired. The string to be calculated
rawOptional. Specifies hex or binary output format:TRUE – Raw 16 character binary formatFALSE – Default. 32 character hex number
PHP md5() method

examples of the MD5() function

Example 1. In this example, we calculate the MD5 hash of the string “Hello”.

<?php
$str = "Hello";
echo md5($str);
?>

Example 2. In this example, we print the result of md5().

<?php
$str = "Hello";
echo "The string: ".$str."<br>";
echo "TRUE - Raw 16 character binary format: ".md5($str, TRUE)."<br>";
echo "FALSE - 32 character hex number: ".md5($str)."<br>";
?>

Example 1. In this example,we print the result of md5() and then test it.

<?php
$str = "Hello";
echo md5($str);

if (md5($str) == "8b1a9953c4611296a827abf8c47804d7")
  {
  echo "<br>Hello world!";
  exit;
  }
?>
PHP ltrim() Function
PHP md5_file() Function

Add comment

Tutor Network

Share this

Learn PHP from A to Z