wp_is_stream

函数
wp_is_stream ( $path )
参数
  • (string) $path The resource path or URL.
    Required:
返回值
  • (bool) True if the path is a stream URL.
定义位置
相关方法
wp_filesystemwp_insert_sitewp_list_sortwp_parse_strwp_stream_image
引入
3.5.0
弃用
-

wp_is_stream: 这个函数用来检查一个给定的变量是否是PHP中的流资源。它接收一个变量作为参数,如果它是流资源,则返回 true,否则返回 false。

测试给定的路径是否是一个流URL。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function wp_is_stream( $path ) {
$scheme_separator = strpos( $path, '://' );
if ( false === $scheme_separator ) {
// $path isn't a stream.
return false;
}
$stream = substr( $path, 0, $scheme_separator );
return in_array( $stream, stream_get_wrappers(), true );
}
function wp_is_stream( $path ) { $scheme_separator = strpos( $path, '://' ); if ( false === $scheme_separator ) { // $path isn't a stream. return false; } $stream = substr( $path, 0, $scheme_separator ); return in_array( $stream, stream_get_wrappers(), true ); }
function wp_is_stream( $path ) {
	$scheme_separator = strpos( $path, '://' );

	if ( false === $scheme_separator ) {
		// $path isn't a stream.
		return false;
	}

	$stream = substr( $path, 0, $scheme_separator );

	return in_array( $stream, stream_get_wrappers(), true );
}

常见问题

FAQs
查看更多 >