How to detect if a file is being included or directly ran

前端 未结 6 931
春和景丽
春和景丽 2021-01-20 00:09

I have a php file that I include in my php script, but I don\'t want people to be able to directly run the file(without being included). How can I prevent that from happenin

6条回答
  •  悲&欢浪女
    2021-01-20 00:56

    Included PHP files should contain class/function/variable definitions, not inline logic/output.

    Running them directly is then, essentially, a no-op.

提交回复
热议问题