php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #45944 fsockopen examples of argument passing do not conform to definition
Submitted: 2008-08-29 03:30 UTC Modified: 2008-08-29 08:18 UTC
From: steve at ssgreenberg dot name Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: Irrelevant OS: Any
Private report: No CVE-ID: None
 [2008-08-29 03:30 UTC] steve at ssgreenberg dot name
Description:
------------
The description of fsockopen is:

resource fsockopen  ( string $hostname  [, int $port  [, int &$errno  [, string &$errstr  [, float $timeout  ]]]] )

Example #1 shows:

$fp = fsockopen("www.example.com", 80, $errno, $errstr, 30);

Example #2 shows:

$fp = fsockopen("udp://127.0.0.1", 13, $errno, $errstr);

Most user supplied example contain the same error.  Only one user supplied example before mine showed the correct argument passing:

$fp = fsockopen('status.icq.com', 80, &$errno, &$errstr, 8);

If there is no error when fsockopen is passed control, then the wrong argument passing is not noticeable. I have not come up with an example to force an error to see what would happen.

I am not sure how this bug report relates Bug #24429.

If passing arguments by reference is deprecated, then the examples may be right and the description of the function may be wrong.

Reproduce code:
---------------
Examples of good and bad code supplied in the description.

Expected result:
----------------
If the arguments to fsockopen are passed correctly and there is an operational error when fsockopen is called, then it will be possible to tell the user what went wrong.  

Actual result:
--------------
If fsockopen incurs an error during its operation and the arguments for recording the error are passed incorrectly, then seemingly unexplainable behavior could result.  Probably no useful error message will be available to explain the problem to the user.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-08-29 04:16 UTC] steve at ssgreenberg dot name
I just noticed that when I try pass by reference, I do get the message:

Warning: Call-time pass-by-reference has been deprecated;

I don't know how I missed this.  So is the the description of fsockopen at http://us.php.net/fsockopen incorrect?  Or what?
It is not clear from the explanation of the fix for Bug #24429.
what was actually fixed.
 [2008-08-29 05:25 UTC] steve at ssgreenberg dot name
Perhaps I am just misreading the documentation.  

The description declares the argument as passed by reference, but I should not use the & when I pass the argument.  Therefore the documentation and the example without the & are correct.  The examples with the & are incorrect.
 [2008-08-29 08:18 UTC] bjori@php.net
You should not pass &$arg to functions receiving arguments by reference.
The function description is correct.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Sun Jun 14 22:00:01 2026 UTC