(PHP 5, PHP 7, PHP 8)
libxml_set_streams_context — 設定下一個 libxml 文件載入或寫入的串流上下文
不回傳任何值。
當非串流資源傳遞給 context
時,會拋出 TypeError。
版本 | 說明 |
---|---|
8.4.0 |
現在,當傳遞非串流資源給 context 參數時,libxml_set_streams_context() 會拋出 TypeError 例外,而不是在稍後使用 context 時才拋出。 |
範例 #1 libxml_set_streams_context() 的使用範例
<?php
$opts = array(
'http' => array(
'user_agent' => 'PHP libxml agent',
)
);
$context = stream_context_create($opts);
libxml_set_streams_context($context);
// 透過 HTTP 請求檔案
$doc = DOMDocument::load('http://www.example.com/file.xml');
?>