
- PHP 7 Tutorial
- PHP 7 - Home
- PHP 7 - Introduction
- PHP 7 - Performance
- PHP 7 - Environment Setup
- PHP 7 - Scalar Type Declarations
- PHP 7 - Return Type Declarations
- PHP 7 - Null Coalescing Operator
- PHP 7 - Spaceship Operator
- PHP 7 - Constant Arrays
- PHP 7 - Anonymous Classes
- PHP 7 - Closure::call()
- PHP 7 - Filtered unserialize()
- PHP 7 - IntlChar
- PHP 7 - CSPRNG
- PHP 7 - Expectations
- PHP 7 - use Statement
- PHP 7 - Error Handling
- PHP 7 - Integer Division
- PHP 7 - Session Options
- PHP 7 - Deprecated Features
- PHP 7 - Removed Extensions & SAPIs
- PHP 7 Useful Resources
- PHP 7 - Quick Guide
- PHP 7 - Useful Resources
- PHP 7 - Discussion
PHP Context Parameters
Introduction
Context parameters allow customization of access to filesystem and other stream wrappers. To configure a stream, PHP has stream_context_set_params() function.
Syntax
stream_context_set_params ( resource $stream_or_context , array $params ) : bool
$stream_or_context can be any of PHP's supported streams/wrappers/contexts
$params is an array with following properties. should be an associative array of the structure − $params['paramname'] = "paramvalue";
context parameters
notification − A user-defined callback to be called whenever a stream triggers a notification. Only for http:// and ftp:// stream wrappers.
The notification callback function has following syntax
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 context/wrapper in use
Example
<?php $ctx = stream_context_create(); stream_context_set_params($ctx, array("notification" => "stream_notification_callback")); file_get_contents("http://php.net/contact", false, $ctx); ?>
- Related Articles
- PHP FTP context options
- PHP HTTP context options
- PHP MongoDB context options
- PHP Phar context options
- PHP Socket context options
- PHP SSL context options
- PHP Zip context options
- CURL context options in PHP
- How to pass reference parameters PHP?
- Using SAP Web Service from SAP by PHP with parameters
- How to get parameters from a URL string in PHP?
- Value parameters vs Reference parameters vs Output Parameters in C#
- Python Context Variables
- Perl Variable Context
- What are default-parameters for function parameters in JavaScript?

Advertisements