Maybe we should move this to an E_STRICT? E_WARNING is more consistent with existing warnings but I wouldn't want to be over strict, especially when making this change a couple of weeks before release.
We could escalate the warning for 5.1 if we feel we need to do so.


Andi

At 11:33 AM 6/24/2004 +1000, Aidan Lister wrote:
> But since there's no BC need to allow resources in array initialization,
> then sure, leave it to the scripter to cast it to an int if that's REALLY
> what they want. (Again "why?" comes to mind).

PEAR::DB uses this method - I'm seeing a million errors on sites that have
updated to latest CVS version.

You're forced to i use this method if you want to link a resource back to
it's creation information.

If you have an array of IPs, and you create an array of resources from each
IP, a third array linking the IP back to the casted interger value of the
resource is required if you want to get the IP back. (This is very confusing
to write).

Here's an example:

<?php
$servers[] = "139.134.253.11:27025";
$servers[] = "203.114.130.7:27015";

foreach ($servers as $server)
{
    list($ip, $port) = explode(':', $server);
    $sock = @fsockopen("udp://" . $ip, $port, $errno, $errstr, 1);
    if ($sock !== false)
    {
        $sockets[] = $sock;
        // Create an array so we can link the socket back to the server
        $server_keys[$sock] = array_search($server, $servers);

    }
}

while (stream_select($r, $w = null, $e = null, 0, calctimeout($maxtime,
$starttime)) !== 0)
{
    ++$i;
    foreach ($r as $socket)
    {
        $response = stream_get_contents($socket);
        // Put the response into an array with the original IP as the key
        $results[$server_keys[$socket]][] = $response;
    }
}
?>

I hope that demonstrates the purpose properly.

Ofcourse this method can still be used, it just requires an extra cast
(which is a cleaner solution anyway).

Regards,
Aidan

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to