PHP sha1_file() Function

PHP sha1_file() Function

The sha1_file() in PHP calculates the sha1 hash of a file and returns the hash (40-character hexadecimal number).

Syntax

sha1_file ( string $filename [, bool $raw_output] ) 

Parameter

filename(required)- This parameter represents the filename of the file to hash.

raw_output(optional)- This parameter takes a Boolean value and returns the digest in raw binary format with a length of 20 if Boolean TRUE is passed.

Return

This function returns a string on success, FALSE otherwise.

Example 1

text.txt

Hello World

Test.php

 $filename = "test.txt";
$sha1file = sha1_file($filename);
echo $sha1file;
?>

Output

aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d

Related Topics

PHP print_r() Function

PHP print_r() Function The print_r() function in PHP displays the information stored in a variable. Syntax print_r (mixed $expression [, bool $return] ) Parameter expression(required)- This parameter represents the expression to be printed. return(optional)- This parameter is used to store the output of...

2 minutes read.

PHP Variables

PHP Variable is the name of memory location used to hold the data.  In PHP, variable starts with $ symbol. Rules for PHP Variables. Variable starts with $ sign. Variable name...

2 minutes read.

PHP chr() Function

PHP chr() Function The chr() function in PHP generates a single byte string from a number and returns a one-character string containing the character as specified by the unsigned integer. Syntax chr(bytevalue);    Parameter bytevalue(required)- This...

1 minute read.

PHP convert_uuencode() Function

PHP convert_uuencode() Function The convert_uuencode() function in PHP is used to encode a string and returns the uuencoded data. Syntax convert_uuencode ( string $data ) Parameter data(required)- This parameter represents the data to be encoded. Return This function returns the uuencoded data or FALSE on failure. Example 1 <?php //...

2 minutes read.

PHP is_long() Function

The PHP is_long () function in PHP is used to find whether a variable is an integer or not. It returns a Boolean value true if the parameter var is integer else it returns...

1 minute read.

PHP strcasecmp() Function

PHP strcasecmp() Function The strcasecmp() function in PHP compares two strings. It is a binary-safe case-insensitive string function. Syntax strcasecmp ( string $str1 , string $str2 ) Parameter str1(required)- This parameter represents the first string. str2(required)- This parameter represents the second string. Return This function returns a value less than( <...

1 minute read.

PHP doubleval() Function

PHP doubleval() Function The doubleval() function in PHP is used to give the float value of a variable. This function is an alias of floatval(). Syntax doubleval ( mixed $var ) Parameter var(required)- This parameter represents the name of the variable that...

1 minute read.

PHP array() function

PHP array() function The array() function in PHP is used to create an array. Syntax array ([ mixed $... ] ) Parameter …(optional)- This parameter represents the elements’ values along with keys of the array. The syntax of this is as follows: "index => values"...

1 minute read.

PHP array_replace() Function

PHP array_replace() Function The array_replace() function in PHP replaces the elements from passed arrays into the first array with values having the same keys in each of the following arrays. Syntax array_replace ( array $array1 [, array $... ] ) Parameter array(required)- This parameter represents...

1 minute read.

PHP array_uintersect() Function

PHP array_uintersect() Function The array_uintersect() function in PHP calculates the intersection of arrays by comparing the data by a callback function. It returns an array containing all the values of the first input array that are...

2 minutes read.

Python Set pop() method

Python Set pop() method The set.pop() method in Python removes an arbitrary element (random item) from the set and returns the element removed. Syntax set.pop()  Parameter NA Return This method returns an arbitrary (random) element from the set. Example 1 #...

1 minute read.

PHP natcasesort() Function

PHP natcasesort() Function The natcasesort() function in PHP Sort an array using a case insensitive "natural order" algorithm while maintaining the keys. Syntax natcasesort ( array &$array ) Parameter array(required)- This parameter represents the input array. Return This parameter returns a Boolean...

1 minute read.

PHP strnatcmp() Function

PHP strnatcmp() Function The strnatcmp() function in PHP compares two strings using a "natural" algorithm. It is case-sensitive. Syntax strnatcmp ( string $str1 , string $str2 ) Parameter str1(required)- This parameter represents the first string. str2(required)- This parameter represents the second string. Return This function returns a value less than(...

1 minute read.

PHP Super Global Variables

There are various predefine “superglobals” in PHP. These variables can easily accessible in function or class. Following are the superglobals variables: $GLOBALS $_SERVER $_REQUEST $_POST $_GETetc. PHP $GLOBALS The “$GLOBAL” isa keyword that...

2 minutes read.

PHP array_unshift() Function

PHP array_unshift() Function The array_unshift () function in PHP prepends one or more elements to the beginning or front of an array. It returns the new number of elements in the array. Syntax array_unshift ( array &$array [, mixed $... ] ) Parameter array(required)- This array represents...

1 minute read.

PHP array_diff_key () Function

PHP array_diff_key () Function The array_diff_key () Function in PHP compares the keys from array1 against the keys from arrays. It returns an array containing all the entries from array1 whose keys are absent from all other arrays. This function is like array_diff () except that...

1 minute read.

PHP metaphone() Function

PHP metaphone() Function The metaphone() function in PHP calculates the metaphone key (representing how a string sounds or pronounced) of a string. This function is used to text search and text matching or spelling...

1 minute read.

PHP For Loops

PHP for loop is used when the specified condition is predefined. Syntax: for (initialization; condition; increment/decrement ) { code to be executed; } Example <!DOCTYPE html> <html> <head> <title>PHP Tutorial</title> </head> <body> <?php echo " Print counting using for loop"."<br>"; for($i=1;$i<=5;$i++){ echo $i."<br>"; } ?> </body> </html> Output Print counting using...

1 minute read.

PHP arsort() function

PHP arsort() function The arsort() function in PHP sorts an array in the reverse order and maintains the index association Syntax arsort ( array &$array [, int $sort_flags = SORT_REGULAR ] ) Parameter array(required)- This parameter represents the input array. sort_flags (optional)- This parameter is used to modify the behavior...

2 minutes read.

PHP implode() Function

PHP implode() Function The implode() function in PHP joins the specified array elements with a string. Syntax implode ( string $glue, array $pieces ) Parameter glue(optional)- It specifies what to put between the array elements. pieces(required)- This parameter represents...

1 minute read.