所以,我在使用 file_get_contents 的 PHP 中遇到了一些麻烦......
我正在使用此代码。
之前,如果我使用找不到的哈希 (bdfccf20b1db88d835c27685ac39f874) 运行它,它将返回:
fcf1eed8596699624167416a1e7e122e - found: octopus (Google)
bed128365216c019988915ed3add75fb - found: passw0rd (Google)
d0763edaa9d9bd2a9516280e9044d885 - found: monkey (Google)
dfd8c10c1b9b58c8bf102225ae3be9eb - found: 12081977 (Google)
ede6b50e7b5826fe48fc1f0fe772c48f - found: 1q2w3e4r5t6y (Google)
bdfccf20b1db88d835c27685ac39f874
Warning: file_get_contents(http://md5.gromweb.com/query/bdfccf20b1db88d835c27685ac39f874): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
in /Users/mihir/MD5Decryptor.php on line 44
Catchable fatal error: Argument 2 passed to MD5Decryptor::dictionaryAttack() must be an array, boolean given, called in /Users/mihir/MD5Decryptor.php on line 56 and defined in /Users/mihir/MD5Decryptor.php on line 25
为了停止警告,我改变了
if ($response = file_get_contents($url)) {
在第 43 行到
$response = @file_get_contents($url);
if ($response) {
并且输出变为
fcf1eed8596699624167416a1e7e122e - found: octopus (Google)
bed128365216c019988915ed3add75fb - found: passw0rd (Google)
d0763edaa9d9bd2a9516280e9044d885 - found: monkey (Google)
dfd8c10c1b9b58c8bf102225ae3be9eb - found: 12081977 (Google)
ede6b50e7b5826fe48fc1f0fe772c48f - found: 1q2w3e4r5t6y (Google)
bdfccf20b1db88d835c27685ac39f874
Catchable fatal error: Argument 2 passed to MD5Decryptor::dictionaryAttack() must be an array, boolean given, called in /Users/mihir/MD5Decryptor.php on line 56 and defined in /Users/mihir/MD5Decryptor.php on line 25
我怎样才能发现错误?如,如果未找到哈希,我如何修改脚本以返回“未找到哈希”而不完全崩溃?
提前致谢...