|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53135 I have PHP >5 and have a call-time pass-by-reference problem
Submitted: 2010-10-22 10:23 UTC Modified: 2010-10-22 10:32 UTC
From: josh dot richard at gmail dot com Assigned:
Status: Not a bug Package: Sockets related
PHP Version: Irrelevant OS: CentOS 5.5
Private report: No CVE-ID: None
 [2010-10-22 10:23 UTC] josh dot richard at gmail dot com
I'm trying to use fsocketopen() to test a server connection- to see if it's online or offline.

Even the manual says I can call it like this:

$connection = fsockopen("", 80, $errno, $errstr, 30);

However, I get this warning message when doing so:

PHP Warning:  Call-time pass-by-reference has been deprecated - argument passed by value;  If you would like to pass it by reference, modify the declaration of fsockopen().  If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file.  However, future versions may not support this any longer. 

Is there another way to declare fsocketopen()??? I see nothing about this!!

Test script:
// This value is either OR
$serverAddress = $_POST[server];

@list($addr,$port)= explode (':', $serverAddress);
if (empty($port)) {
$port = 80;
// Test the server connection
$connection = @fsockopen($addr, $port, &$errno, &$errstr, 30);
	if (!$connection) {
	echo $addr . ":" . $port . " is currently DOWN";
	} else {
	echo $addr . ":" . $port . " is currently UP";

Expected result:
Not expecting any warning!!

Actual result:
Where does this warning come from? I've called fsocketopen() like this for years!!


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-10-22 10:32 UTC]
-Status: Open +Status: Bogus
 [2010-10-22 10:32 UTC]
You shouldn't specify &$errno and &$errstr with the & operator;
simply providing $errno and $errstr will work fine.

Further explanation:

Not a bug; closing.
 [2010-10-22 10:44 UTC] josh dot richard at gmail dot com
Sorry, I misread that page at first. Thanks!
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Thu Jan 27 20:03:37 2022 UTC