For example, here is a
a.php
:
Instead b.php
, a URL is obtained from the user input, which is exactly /a.php?b
:
assert($_GET["wanted"] === '/a.php?b');// 是否存在一个方法whatever, 令:$result = whatever($_GET["wanted"]);echo strtoupper($result); // THESE'S A "B".
These answers are not acceptable:
file_get_contents()
or fopen()
initiate a remote request: The server may not listen localhost, the domain name is also indeterminate, and the originating remote request overhead is too high.
- Redirect: Further processing is needed after getting the returned content.
include
or require_once
: The actual situation can be very complex, including URL mapping and so on, do not know include
which file. In addition, this URL may also be a static file.
Update 20140511:
It seems that because I deliberately hide the problems in the project, so it is difficult to make people clear, very sorry. To put it simply, I was hoping to get an whatever()
implementation.
The problem I encountered in the project was this. A Web page, HTML has some JS and CSS resources, you can directly in-line expansion. If JS and CSS are all static so good, read directly into the file and then replace it with regular. However, some JS is generated dynamically based on user input, so it is necessary to request to these PHP generated JS, and then replaced.
All URLs are rewrite to index.php in the project, and then the URL mapping in index.php. Including the current Web page, and want to get the content of JS, all through index.php and then generated.
Reply content:
For example here is a a.php
:
Instead b.php
, a URL is obtained from the user input, which is exactly /a.php?b
:
assert($_GET["wanted"] === '/a.php?b');// 是否存在一个方法whatever, 令:$result = whatever($_GET["wanted"]);echo strtoupper($result); // THESE'S A "B".
These answers are not acceptable:
file_get_contents()
or fopen()
initiate a remote request: The server may not listen localhost, the domain name is also indeterminate, and the originating remote request overhead is too high.
- Redirect: Further processing is needed after getting the returned content.
include
or require_once
: The actual situation can be very complex, including URL mapping and so on, do not know include
which file. In addition, this URL may also be a static file.
Update 20140511:
It seems that because I deliberately hide the problems in the project, so it is difficult to make people clear, very sorry. To put it simply, I was hoping to get an whatever()
implementation.
The problem I encountered in the project was this. A Web page, HTML has some JS and CSS resources, you can directly in-line expansion. If JS and CSS are all static so good, read directly into the file and then replace it with regular. However, some JS is generated dynamically based on user input, so it is necessary to request to these PHP generated JS, and then replaced.
All URLs are rewrite to index.php in the project, and then the URL mapping in index.php. Including the current Web page, and want to get the content of JS, all through index.php and then generated.
I don't seem to understand what the Lord is asking.
The main question is whether there is a PHP script that gets the requested response without requesting any remote resources.
And then himself hehe.
Later thought, perhaps the main question to ask is, if there is such an accessible resource on the same server, but now only to establish an HTTP connection to know its content, as if this is very expensive, it can not be established HTTP connection, and in what local way to get results?
Really headache, feeling everywhere is the concept of ambiguity and do not understand the truth.
Start serious questions:
In fact, this is a logical problem, the master carefully analysis to know, but the so-called /a.php?b
access results, and not only by a.php
their own decision. For example, if you do not pass the PHP interpreter, the /a.php?b
result of the access is by default * The script text itself. Access to an HTTP resource depends on what your HTTP server will output based on the requests received. It is easy to understand that different HTTP servers, different configurations, different code will produce different results. So in order to get the content of the master's expectation every time, the play has to do a full set (this seems to be a theory of what the conclusion, who can help to add). Of course, if the master knows some preconditions, simplifying some of the intermediate steps under controllable circumstances may also result in 100%.
- Why is it by default, because if I use Perl's interpreter, it will return to the unthinkable.
There is a way to achieve what you say the request, the idea is this:
1) The first idea: Run a.php in the run b.php, and capture a.php's standard output as the return of the method, which needs to be constructed in advance to run the a.php environment, such as setting the query value, that is a.php.
A) How to run the a.php and capture the standard output, you can refer to pipe (pipe) mode;
b) How to construct the operating environment, you can refer to the CGI environment variables to set.
c) This approach is required to run a process for additional processing, so performance is not very good, bad for online use.
2) The second idea: to implement a simple PHP interpreter to run this a.php;
A) This method is more complex, but the performance is better than the first one.
3) There may be some third-party or open source class library to implement the existing functions, this need you to find yourself.
And then probably listen to what you said, feeling from the demand analysis, you choose the solution should be a problem, so it caused so troublesome way of realization. Of course, it is unclear whether the actual difficulties of your project can only be taken this way, but if you start from scratch, the recommendation is to abstract the implementation of the a.php, and then a.php and b.php respectively call is a more reasonable solution.
I don't know what you're trying to do, there's something wrong with your plan.