how to pass a variable through the require() or include() function of php?

后端 未结 9 2121
梦如初夏
梦如初夏 2021-02-06 21:34

when I use this:

require(\"diggstyle_code.php?page=$page_no\");

the warning is :failed to open stream: No error in C:\\xampp\\htdocs\\4ajax\\ga

9条回答
  •  太阳男子
    2021-02-06 22:21

    if I've correctly understood, what you need is to call the file diggstyle_code.php passing an argument, so that no one can call that file and make it work, rather than your main file. Am I right?

    Thus supposing that your "main.php" has the lines

    require("diggstyle_code.php?page=$page_no");
    

    it means that: if anyone calls "main.php" gets diggstyle_code.php running. But if anybody in any manner calls directly diggstyle_code.php he/she shoudl get nothing.

    If I am right on my understanding, a way to achieve this, is to include into the main file a variable or a constant, that will be scoped by diggstyle_code.php

    Thus for instance: 'main.php'

    
    

    and now diggstyle_code.php

    
    

提交回复
热议问题