相关疑难解决方法(0)

确定文件是否为空(php)的最佳方法是什么?

我在我的模板中包含了custom.css文件,以允许网站所有者添加自己的css规则.但是,当我发送文件时,它是空的,如果他们没有添加任何规则,就没有意义加载它.

确定它是否空的最佳方法是什么?

if ( 0 == filesize( $file_path ) )
{
    // file is empty
}

// OR:

if ( '' == file_get_contents( $file_path ) )
{
    // file is empty
} 
Run Code Online (Sandbox Code Playgroud)

php

38
推荐指数
4
解决办法
6万
查看次数

标签 统计

php ×1