Stream_notification_callback doesn't seem to work

http://www.php.net/manual/en/function.stream-notification-callback.php

In that, I did not expect the following to result in an error:

<?php
stream_context_create(array('notification' => 'callback'));

... but he does:

Warning: stream_context_create(): options should have the form ["wrappername"]["optionname"] = $value in /path/to/file.php on line 2

This also causes an error:

<?php
$ctx = stream_context_create();
stream_context_set_option($ctx, array('notification' => 'callback'));

Oddly enough, the code in the example stream_notification_callbackdoes not cause an error. But since it uses stream_context_set_paramsinstead stream_context_set_option, I'm not sure if he actually does something lol for this:

stream_context_set_params vs. stream_context_set_option

+5
source share
1 answer

The function expects an array inside the array, so the code should be changed to:

stream_context_create(array('wrapper' => array ('notification' => 'callback')));
0
source

All Articles