wpseek.com
WordPress开发者和主题制作者的搜索引擎



wp_filesize › WordPress Function

Since6.0.0
已弃用n/a
wp_filesize ( $path )
参数:
  • (string) $path Path to the file.
    Required: Yes
链接:
返回:
  • (int) The size of the file in bytes, or 0 in the event of an error.
定义在:
文档:

Wrapper for PHP filesize with filters and casting the result as an integer.



源码

function wp_filesize( $path ) {
	/**
	 * Filters the result of wp_filesize before the PHP function is run.
	 *
	 * @since 6.0.0
	 *
	 * @param null|int $size The unfiltered value. Returning an int from the callback bypasses the filesize call.
	 * @param string   $path Path to the file.
	 */
	$size = apply_filters( 'pre_wp_filesize', null, $path );

	if ( is_int( $size ) ) {
		return $size;
	}

	$size = file_exists( $path ) ? (int) filesize( $path ) : 0;

	/**
	 * Filters the size of the file.
	 *
	 * @since 6.0.0
	 *
	 * @param int    $size The result of PHP filesize on the file.
	 * @param string $path Path to the file.
	 */
	return (int) apply_filters( 'wp_filesize', $size, $path );
}