stream_wrapper_unregister
取消注册URL包装器
PHP 5.1.0及更高版本
stream_wrapper_unregister 函数用于取消对某个自定义协议的流包装器的注册。这个函数可以将某个已注册的流包装器从流包装器堆栈中移除,使其不再可用。
bool stream_wrapper_unregister(string $protocol);
protocol (string) - 要取消注册的协议名(例如,"ftp", "http")。
如果取消注册成功,则返回 true;如果取消注册失败,则返回 false。
以下是使用 stream_wrapper_unregister 函数的示例:
<?php
// 假设我们已经注册了一个自定义的协议 'myprotocol'
stream_wrapper_register('myprotocol', 'MyProtocolWrapper');
<p>// 取消注册 'myprotocol' 协议<br>
if (stream_wrapper_unregister('myprotocol')) {<br>
echo "协议 'myprotocol' 已成功取消注册。\n";<br>
} else {<br>
echo "无法取消注册 'myprotocol' 协议。\n";<br>
}<br>
?><br>
在此示例中,我们首先通过 stream_wrapper_register 函数注册了一个名为 'myprotocol' 的自定义协议。然后,使用 stream_wrapper_unregister 函数将该协议取消注册。如果取消注册成功,输出 "协议 'myprotocol' 已成功取消注册。",否则输出 "无法取消注册 'myprotocol' 协议。"。