
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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); ?>
Advertisements