Home > Backend Development > PHP Tutorial > PHP context parameters

PHP context parameters

WBOY
Release: 2023-08-31 09:50:01
forward
913 people have browsed it

PHP context parameters

Introduction

Context parameters allow customizing access to the file system and other stream wrappers. To configure streams, PHP has the stream_context_set_params() function.

Syntax

stream_context_set_params ( resource $stream_or_context , array $params ) : bool
Copy after login

$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";

Context Parameters

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

Syntax

stream_notification_callback ( int $notification_code , int $severity , string $message , int $message_code , int $bytes_transferred , int $bytes_max ) : void
Copy after login

Options - Array of supported options corresponding to the 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);
?>
Copy after login

The above is the detailed content of PHP context parameters. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template