Best way to determine if a file is empty (php)?

前端 未结 5 1431
迷失自我
迷失自我 2020-12-01 15:40

I\'m including a custom.css file in my template to allow site owners to add their own css rules. However, when I ship the file, its empty and there\'s no sense loading it if

5条回答
  •  自闭症患者
    2020-12-01 16:04

    file_get_contents() will read the whole file while filesize() uses stat() to determine the file size. Use filesize(), it should consume less disk I/O and much less memory.

提交回复
热议问题