0

“search.php”中的搜索表单位于供应商的服务器上,并且已设置好以便我的站点可以显示它。URL 是: http: //mysite.com/search.php

搜索结果页面位于供应商的服务器上,也在一个名为“result.php”的单独文件中。它也已配置,因此 URL 如下所示:http://mysite.com/result.php

我想在“result.php”文件中插入“search.php”表单,这样用户就不必在页面之间来回切换。

我试过了:

 <?php
 include 'http://mysite.com/search.php';
 ?>   

它不起作用,然后我意识到我需要将“allow_url_fopen”设置为yes才能在include语句中使用URL。这不是我想做的事情,因为我在这里阅读了其他帖子,其中涉及安全问题。

4

3 回答 3

0

You can just do

<?php
include $_SERVER['DOCUMENT_ROOT']"./search.php";
?>
于 2012-10-01T13:21:25.770 回答
0

I'm not sure you can include another server's php file, allow_url_fopen and allow_url_include are to get the file output of the designated url, i mean, the final result, you won't be able to use the variables or functions from that script.

try using file_get_contents(), or if you are displaying final results anyway, you could just use an iFrame

于 2012-10-01T13:30:27.037 回答
0

你可以试试

include __dir__  . "/search.php";
于 2012-10-01T13:26:11.613 回答