|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-08-24 17:46 UTC] rafagd at gmail dot com
Description: ------------ --- From manual page: http://www.php.net/function.geoip-country-code-by-name --- On development environment, with E_NOTICE enabled, this function will throw an uncatchable and undocumented notice if it can't find the ip, which might break layouts or protocols. === Suggestion === Remove the notice, the function already inform you it couldn't find the IP by returning false. === Workaround === Add @ before the function name, disabling any error messages it might throw. Test script: --------------- <?php $name = geoip_country_code_by_name("127.0.0.1"); header("Content-type: application/json"); if ($name) { echo json_encode(array( "name" => $name )); } else { echo json_encode(array( "error" => "Not Found" )); } ?> Expected result: ---------------- A json-encoded response like this: { error : "Not Found" } Actual result: -------------- <b>Notice</b>: geoip_country_code_by_name(): Host 127.0.0.1 not found in <b>/path/to/file.php</b> on line <b>3</b><br /> { error : "Not Found" } PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 16:00:01 2025 UTC |
Bug still reproduced for this source code <?php error_reporting(-1); ini_set('display_errors', 0); var_dump(geoip_country_code_by_name('154.106.91.217')); PHP Notice: geoip_country_code_by_name(): Host 154.106.91.217 not found in /root/t.php on line 4