stream_notification_callback
Description
The stream_notification_callback of Stream for PHP a callback function for the notification context parameter.
Syntax
stream_notification_callback(
int $notification_code,
int $severity,
?string $message,
int $message_code,
int $bytes_transferred,
int $bytes_max
): voidParameters
notification_code
One of the STREAM_NOTIFY_* notification constants.
severity
One of the STREAM_NOTIFY_SEVERITY_* notification constants.
message
Passed if a descriptive message is available for the event.
message_code
Passed if a descriptive message code is available for the event.
The meaning of this value is dependent on the specific wrapper in use.
bytes_transferred
If applicable, the bytes_transferred will be populated.
bytes_max
If applicable, the bytes_max will be populated.
Return
No value is returned.
Examples
1
<?
function stream_notification_callback($notification_code, $severity, $message, $message_code, $bytes_transferred, $bytes_max)
{
switch($notification_code)
{
case STREAM_NOTIFY_RESOLVE:
case STREAM_NOTIFY_AUTH_REQUIRED:
case STREAM_NOTIFY_COMPLETED:
case STREAM_NOTIFY_FAILURE:
case STREAM_NOTIFY_AUTH_RESULT:
var_dump($notification_code, $severity, $message, $message_code, $bytes_transferred, $bytes_max);
break;
case STREAM_NOTIFY_CONNECT:
echo "connect";
break;
case STREAM_NOTIFY_MIME_TYPE_IS:
echo "mime type: " . $message;
break;
case STREAM_NOTIFY_FILE_SIZE_IS:
echo "file size: " . $bytes_max;
break;
case STREAM_NOTIFY_REDIRECTED:
echo "redirected: " . $message . "\n";
break;
case STREAM_NOTIFY_PROGRESS:
echo "progress: " . $bytes_transferred;
break;
}
echo "\n";
}
$stream_or_context = stream_context_create();
$params =
[
"notification" => "stream_notification_callback"
];
stream_context_set_params($stream_or_context, $params);
$filename = "http://osbo.com/";
$use_include_path = false;
file_get_contents($filename, $use_include_path, $stream_or_context);
connect mime type: text/html file size: 795 redirected: https://osbo.com/ connect mime type: text/html; charset=UTF-8 progress: 0 progress: 993 progress: 0 progress: 993 progress: 9185 progress: 15987 progress: 24179 progress: 32371 progress: 40563 progress: 48755 progress: 56947 progress: 65139 progress: 65538 progress: 73730 progress: 81922 progress: 90114 progress: 98306 progress: 106498 progress: 114690 progress: 122882 progress: 131074 progress: 131083 progress: 139275 progress: 147467 progress: 155659 progress: 163851 progress: 172043 progress: 180235 progress: 188427 progress: 196619 progress: 196628 progress: 197996 progress: 206188 progress: 212990 progress: 221182 progress: 229374 progress: 233156 progress: 234524 progress: 242716 progress: 249518 progress: 257710 progress: 262180 progress: 270372 progress: 278564 progress: 286756 progress: 294948 progress: 303140 progress: 311332 progress: 319524 progress: 327716 progress: 327725 progress: 335917 progress: 344109 progress: 352301 progress: 360493 progress: 368685 progress: 376877 progress: 385069 progress: 393261 progress: 393270 progress: 401462 progress: 409654 progress: 417846 progress: 426038 progress: 434230 progress: 442422 progress: 450614 progress: 458806 progress: 458815 progress: 460183 progress: 468375 progress: 475177 progress: 483369 progress: 491561 progress: 499753 progress: 507945 progress: 516137 progress: 524329 progress: 524360 progress: 532552 progress: 540744 progress: 548936 progress: 557128 progress: 565320 progress: 573512 progress: 581704 progress: 583809 progress: 583814
Links
Stream
- stream_bucket_append
- stream_bucket_make_writeable
- stream_bucket_new
- stream_bucket_prepend
- stream_context_create
- stream_context_get_default
- stream_context_get_options
- stream_context_get_params
- stream_context_set_default
- stream_context_set_option
- stream_context_set_options
- stream_context_set_params
- stream_copy_to_stream
- stream_filter_append
- stream_filter_prepend
- stream_filter_register
- stream_filter_remove
- stream_get_contents
- stream_get_filters
- stream_get_line
- stream_get_meta_data
- stream_get_transports
- stream_get_wrappers
- stream_is_local
- stream_isatty
- stream_register_wrapper
- stream_resolve_include_path
- stream_select
- stream_set_blocking
- stream_set_chunk_size
- stream_set_read_buffer
- stream_set_timeout
- stream_set_write_buffer
- stream_socket_accept
- stream_socket_client
- stream_socket_enable_crypto
- stream_socket_get_name
- stream_socket_pair
- stream_socket_recvfrom
- stream_socket_sendto
- stream_socket_server
- stream_socket_shutdown
- stream_supports_lock
- stream_wrapper_register
- stream_wrapper_restore
- stream_wrapper_unregister