1.2.357. Directly Use File¶
Some PHP functions have a close cousin that work directly on files. This is faster and less code to write.
md5() => md5_file()
parsekit_compile_string() => parsekit_compile_file()
yaml_parse() => yaml_parse_file()
hash_hmac() => hash_mac_file()
recode() => recode_file()
recode_string() => recode_file()
<?php
// Good way
$file_hash = hash_file('sha512', 'example.txt');
// Slow way
$file_hash = hash('sha512', file_get_contents('example.txt'));
?>
1.2.357.1. Suggestions¶
1.2.357.2. Specs¶
Short name |
Structures/DirectlyUseFile |
Rulesets |
|
Exakat since |
1.5.5 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Instant (5 mins) |
Precision |
Very high |
Available in |