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

后端 未结 9 2120
梦如初夏
梦如初夏 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:11

    this should work, but it's quite a dirty hack:

    $_GET['page'] = $page_no;
    require('diggstyle_code.php');
    

    you probably want to refactor your code to use functions and/or objects and call them from your files instead of including them (spaghetti code alert)

提交回复
热议问题