php.net |  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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: josh dot richard at gmail dot com
New email:
PHP Version: OS:

 

 [2010-10-22 10:23 UTC] josh dot richard at gmail dot com
Description:
------------
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("www.example.com", 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 example.com OR example.com:port
$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!!

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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

Further explanation: http://php.net/language.references.pass

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