Prevent direct access to a php include file

后端 未结 30 1395
盖世英雄少女心
盖世英雄少女心 2020-11-22 06:32

I have a php file which I will be using as exclusively as an include. Therefore I would like to throw an error instead of executing it when it\'s accessed directly by typing

30条回答
  •  不要未来只要你来
    2020-11-22 07:20

    You don't have right permission to access this file directly.");
    }
    ?>
    

    place the code above in the top of your included php file.

    ex:

    You don't have right permission to access this file directly.");
    }
    
        // do something
    ?>
    

提交回复
热议问题