PHP—“Defined or Exit” at the beginning of many files?

前端 未结 3 1622
孤独总比滥情好
孤独总比滥情好 2021-01-14 16:47

I have been inspecting some PHP source codes and I more often than not find files starting with

defined(\'__someconstant__\') or exit();

I

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-14 17:11

    Adding to @NullUserException's answer...

    Yes there are other ways of preventing a file from being accessed directly (.htaccess being one), but for software that is shared with a wide audience, you can't really rely on those technologies being there. You can rely on a simple condition at the top of the files though.

提交回复
热议问题