บทนำ
Context parameters อนุญาตให้ปรับแต่งการเข้าถึง filesystem และ stream wrappers อื่นๆ เพื่อกำหนดค่า stream PHP มีฟังก์ชัน stream_context_set_params()
ไวยากรณ์
stream_context_set_params ( resource $stream_or_context , array $params ) : bool
$stream_or_context สามารถเป็น stream/wrapper/context ใดๆ ที่ PHP รองรับ
$params เป็น array ที่มี properties ดังนี้ ควรเป็น associative array โครงสร้าง - $params['paramname'] = "paramvalue";
Context parameters
notification - User-defined callback ที่จะถูกเรียกเมื่อ stream กระตุ้น notification เฉพาะ https:// และ ftp:// stream wrappers
Notification callback function มีไวยากรณ์ดังนี้
Syntax
stream_notification_callback ( int $notification_code , int $severity , string $message , int $message_code , int $bytes_transferred , int $bytes_max ) : void
options - Array ของ supported options ที่สอดคล้องกับ context/wrapper ที่ใช้
ตัวอย่าง
<?php $ctx = stream_context_create(); stream_context_set_params($ctx, array("notification" => "stream_notification_callback")); file_get_contents("https://php.net/contact", false, $ctx); ?>