In PHP I've build a webpage that uses include() for loading parts of the website.
However, I now ran into something like a problem:
When I use an url like: data-openov-storingen.php?type=actueel
It gives me this error:
Warning: include(data-storingen.php?type=actueel): failed to open stream: No such file or directory in blablabla
Is it even possible to pass get variables in an include()
url?
include
in this way doesn't fetch a URL, it fetches a file from the filesystem, so there's no such thing as a query string.
You can do this, though:
$_GET['type'] = 'actueel';
include('data-storingen.php');
The include()
function does not access the file via HTTP, it accesses the file through the OS's own file system. So GET variables are not counted. (as they are not part of the file name).
In layman's terms, the point of include is to "copy/paste" all the contents on one file to another on the file, so that you don't have one gigantic file, but a few smaller, more maintainable ones.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With