Simply put:
<? include("open.php"); ?>
VS
<? include("open.php?page=about"); ?>
VS
<? $x="varToPass"; include("open.php"); ?>
Why can this not be done, surely this should have been programmed into. And if not can I edit the raw/core PHP C files to achieve this.
The simple answer. There is no need to pass parameters like this.
include 'open.php?page=about&something=true&more=rubbish';versus
I think it’s quite easy to see which is more readable, and they both achieve exactly what you are trying to do.
The fact is that the
includestatement literally includes the code from the indicated file at the point you reference it.You can treat the file doing the including, as having the source of
open.phpat the exact place you wrote the include statement.Edit:
To answer the second part of your question. Yes you could modify the source and achieve this, but it would be a largely pointless exercise.
Edit 2:
It has also occurred to me that perhaps you think you want to include files by URL.
For example
include 'http://127.0.0.1/open.php?page=about'In this case it is completely possible, as the
httpstream wrapper will be invoked, and variables will be passed to the file you requested.This behaviour is DISABLED BY DEFAULT BECAUSE IT POSES A MASSIVE SECURITY RISK.
You can turn it on by editing the
allow_url_includevalue inphp.ini. But I suggest that you don’t.