1.2.355. Directly Use File

Some PHP functions have a close cousin that work directly on files. This is faster and less code to write.

<?php

// Good way
$file_hash = hash_file('sha512', 'example.txt');

// Slow way
$file_hash = hash('sha512', file_get_contents('example.txt'));

?>

1.2.355.1. Suggestions

1.2.355.2. Specs

Short name

Structures/DirectlyUseFile

Rulesets

All, Suggestions

Exakat since

1.5.5

PHP Version

All

Severity

Minor

Time To Fix

Instant (5 mins)

Precision

Very high

Available in

Entreprise Edition, Exakat Cloud