PHP/fx/stream notification callback: Difference between revisions

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
No edit summary
No edit summary
 
Line 1: Line 1:
{{fmt/title|PHP function: <code>stream_notification_callback()</code>}}
{{page/PHP/fx}}
==About==
==About==
This is the prototype for a callback function. A user-function using this same format will be called when any of several different events occur on a stream.
This is the prototype for a callback function. A user-function using this same format will be called when any of several different events occur on a stream.
Line 8: Line 8:
...and then opening the stream using that context.
...and then opening the stream using that context.


'''However''': [https://www.php.net/manual/en/function.stream-context-set-params.php this page] mentions casually in passing that it is "Only supported for http:// and ftp:// stream wrappers.", wtf.
==Links==
==Links==
===Official===
===Official===
* php.net: [https://www.php.net/manual/en/function.stream-notification-callback.php stream_notification_callback()]
* php.net: [https://www.php.net/manual/en/function.stream-notification-callback.php stream_notification_callback()]

Latest revision as of 22:49, 10 February 2026

Template:Page/PHP/fx

About

This is the prototype for a callback function. A user-function using this same format will be called when any of several different events occur on a stream.

The user's function can be activated as a stream's callback by first creating a context that uses it:

$ctx = stream_context_create();
[[../stream_context_set_params/]]($ctx, array("notification" => "stream_notification_callback"));

...and then opening the stream using that context.

However: this page mentions casually in passing that it is "Only supported for http:// and ftp:// stream wrappers.", wtf.

Official