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
檢視更多 >