Php 如何使用exec而不是header

Php 如何使用exec而不是header,php,Php,我正在使用标题(位置:“http:\\example.com\registrations\export”) 实际上,我的要求是我想在另一个文件中执行http:\test.com\enrollments\export.php链接,但在执行此文件后,它不会重定向到http:\test.com\enrollments\export。它将停留在www.test.com/test.php上 例如:- test.php 在test.php中,使用href本身创建一个链接,只需使用hrefwww.test.c

我正在使用
标题(位置:“http:\\example.com\registrations\export”)

实际上,我的要求是我想在另一个文件中执行http:\test.com\enrollments\export.php链接,但在执行此文件后,它不会重定向到http:\test.com\enrollments\export。它将停留在www.test.com/test.php上

例如:-

test.php
在test.php中,使用href本身创建一个链接,只需使用href
www.test.com/test.php?export=1传递一个参数即可

在test.php中

if(isset($_GET['export']) && $_GET['export']){

include_once("enrollments/export.php");
}
你可以用curl


而不是:

header('Location: http://test.com/enrollments/export');
使用


这将运行export.php,而不会中断test.php中的执行流,也不会重定向。这是最简单的解决方案

你只想执行php文件,而不是重定向,核心是对的吗?你的问题暗示header和exec是相关的?我怎样才能用手提钻代替煎饼呢?这会更好:
include(uuu DIR_uuu.'/enrollments/export.php”)。不需要“一次”,绝对fs路径与绝对http-path1不同。您使用的路径不是相对的(它以斜杠开始)2。相对值是根据“当前工作目录”计算的,该目录并不总是与文件的位置相同
if(isset($_GET['export']) && $_GET['export']){

include_once("enrollments/export.php");
}
    <?php 
$curl = curl_init('http://example.com'); 
curl_setopt($curl, CURLOPT_FAILONERROR, true); 
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); 
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); 
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);   
$result = curl_exec($curl); 
echo $result; 
?>
header('Location: http://test.com/enrollments/export');
include "export.php" #assuming that export.php and test.php are in the same directory