我有以下代码:
<?php
define('ENVIRONMENT', 'tests');
$_POST['id']='AccountPagesView.a_book/45';
$_POST['old_value']='1';
$_POST['value']='2';
header("Location: http://localhost/index.php/welcome/update_record");
?>
我需要在这个脚本中设置 $_POST 数组并通过 url 加载脚本。但是来自 url 的脚本告诉我 $_POST 数组为空。为什么?如何设置 $_POST 数组并通过 url 将其发送到脚本?先感谢您。
更新:我有一些必须测试的代码,并且 url 上有一些脚本"http://localhost/index.php/welcome/update_record"
,它使用 $_POST 数组中的值;所以,我不能改变这个脚本,我想测试它。我该怎么做?
更新2:
<?php
//include ('\application\controllers\welcome.php');
define('ENVIRONMENT', 'tests');
$_POST_DATA=array();
$_POST_DATA['id']='AccountPagesView.a_book/45';
$_POST_DATA['old_value']='1';
$_POST_DATA['value']='2';
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://localhost/index.php/welcome/update_record');
curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST_DATA);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_exec($ch);
?>