Edit report at https://bugs.php.net/bug.php?id=60779&edit=1

 ID:                 60779
 Comment by:         phpmpan at mpan dot pl
 Reported by:        wojtos at gmail dot com
 Summary:            Incorrect return value for getprotobyname
 Status:             Open
 Type:               Bug
 Package:            *Network Functions
 Operating System:   Debian Squeeze
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

This is not a bug in `getprotobyname`. It's a bug in documentation for the 
function. `getprotobyname` returns `FALSE`, not 0 in case of an error. I will 
fill a report for that in a moment. You can close this one.


Previous Comments:
------------------------------------------------------------------------
[2012-01-17 14:19:22] 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


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=60779&edit=1

Reply via email to