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\gallery_core.php on line 198
and the error is:
Failed opening required 'diggstyle_code.php?page=1' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\4ajax\gallery_core.php on line 198
value of the variable $page_no is collected beforehand.
But if I omit the '?page=$page_no part' from the argument of the require function, then no error or warning is shown.
I need to pass the variable when I use the require() function.
require()andinclude()will open the file corresponding to the path/name they receive.Which means that, with your code, you would have to have a file called
diggstyle_code.php?page=1on your disk. That’s obviously not the case, so it fails.Quoting the Variable scope page of the PHP Manual:
In your case, you don’t need to pass the variable. If you have a variable in your current script, it will also exist in the script you include, outside of functions, which have their own scope.
In your main script, you should have:
And in
diggstyle_code.php:Remember that including/requiring a file is exactly the same as copy-pasting its content at the line it’s required.