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

前端 未结 5 1440
迷失自我
迷失自我 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:07

    Using filesize() is clearly better. It uses stat() which doesn't have to open the file at all.

    file_get_contents() reads the whole file.. imagine what happens if you have a 10GB file.

提交回复
热议问题