Home >Backend Development >PHP Tutorial >PHP context parameters
Context parameters allow customizing access to the file system and other stream wrappers. To configure streams, PHP has the stream_context_set_params() function.
stream_context_set_params ( resource $stream_or_context , array $params ) : bool
$stream_or_context can be any stream/wrapper/context supported by PHP
$params is an array with the following properties. Should be an associative array of structures - $params['paramname'] = "paramvalue";
Notifications - User defined whenever a stream triggers a notification The callback will be called. Applies only to http:// and ftp:// stream wrappers.
Notification callback functions have the following syntax
stream_notification_callback ( int $notification_code , int $severity , string $message , int $message_code , int $bytes_transferred , int $bytes_max ) : void
Options - Array of supported options corresponding to the context/wrapper in use
<?php $ctx = stream_context_create(); stream_context_set_params($ctx, array("notification" => "stream_notification_callback")); file_get_contents("http://php.net/contact", false, $ctx); ?>
The above is the detailed content of PHP context parameters. For more information, please follow other related articles on the PHP Chinese website!