|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-01-17 14:19 UTC] wojtos at gmail dot com
Description: ------------ --- From manual page: http://www.php.net/function.getprotobyname#refsect1-function.getprotobyname-returnvalues --- Return for unrecognized protocol is 0 instead of -1. PHP 5.3.3-7+squeeze3 with Suhosin-Patch (cli) (built: Jun 28 2011 13:13:26) Test script: --------------- <?php $protocol = 'BLA'; $get_prot = getprotobyname($protocol); if ($get_prot == -1) { echo 'Invalid Protocol'; } else { echo 'Protocol #' . $get_prot; } ?> Expected result: ---------------- Invalid Protocol Actual result: -------------- Protocol #0 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 09 03:00:01 2025 UTC |
Or you can't... Are you sure that you're receiving 0, not `FALSE`? If yes, than I'm NOT confirming this behaviour with 5.3.9, 5.3-dev, 5.4-dev or trunk-dev (on Arch64). In all four versions `getprotobyname` returns `FALSE`. Also returning 0 seems very strange. PHP just forwards the call to `getprotobyname` from netdb. In case of an error or if a protocol is not found, this function should return `NULL`. PHP checks if the call has returned `NULL` and, if it did, returns `FALSE`. Therefore if you're receiving 0, this would indicate a bug in the host environment, not in PHP itself. -------- BEGIN CODE -------- // ext/standard/basic_functions.c from SVN // ... ent = getprotobyname(name); if (ent == NULL) { RETURN_FALSE; } // ... --------- END CODE ---------