请帮我解决这个问题。
我想从 $_POST 数组中获取数据,但它返回为空,但 php://input 返回所有数据。
这是我的代码:
echo $_SERVER['CONTENT_TYPE'];
$post = file_get_contents('php://input');
print "post data: <pre>";
var_dump($post);
echo "-----------------------<br>";
var_dump($_POST);
输出:
application/x-www-form-urlencodedDATA:
string(6529) "jform%5Bsitename%5D=Test&jform%5Boffline%5D=0&jform%5Bdisplay_offline_message%5D=1&jform%5Boffline_message%5D=This+site+is+down+for+maintenance.%3Cbr+%2F%3E+Please+check+back+again+soon.&jform%5Boffline_image%5D=&jform%5Beditor%5D=tinymce&jform%5Bcaptcha%5D=0&jform%5Baccess%5D=1&jform%5Blist_limit%5D=20&jform%5Bfeed_limit%5D=10&jform%5Bfeed_email%5D=author&jform%5BMetaDesc%5D=&jform%5BMetaKeys%5D=&jform%5Brobots%5D=&jform%5BMetaRights%5D=&jform%5BMetaAuthor%5D=1&jform%5BMetaVersion%5D=0&jform%5Bsef%5D=1&jform%5Bsef_rewrite%5D=0&jform%5Bsef_suffix%5D=0&jform%5Bunicodeslugs%5D=0&jform%5Bsitename_pagetitles%5D=0&jform%5Bcookie_domain%5D=&jform%5Bcookie_path%5D=&jform%5Blog_path%5D=%2Fvar%2Fwww%2Fvhosts%2Fencros.dedibox.fr%2Fhttpdocs%2Ffresh%2Flogs&jform%5Bhelpurl%5D=http%3A%2F%2Fhelp.joomla.org%2Fproxy%2Findex.php%3Foption%3Dcom_help%26keyref%3DHelp%7Bmajor%7D%7Bminor%7D%3A%7Bkeyref%7D&jform%5Bdebug%5D=1&jform%5Bdebug_lang%5D=0&jform%5Bcaching%5D=0&jform%5Bcache_handler%5D=file&jform%5Bcachetime%5D=150000&jform%5Blifetime%5D=15000&jform%5Bsession_handler%5D=database&jform%5Btmp_path%5D=%2Fvar%2Fwww%2Fvhosts%2Fencros.dedibox.fr%2Fhttpdocs%2Ffresh%2Ftmp&jform%5Bgzip%5D=0&jform%5Berror_reporting%5D=default&jform%5Bforce_ssl%5D=0&jform%5Boffset%5D=UTC&jform%5Bftp_enable%5D=0&jform%5Bftp_host%5D=127.0.0.1&jform%5Bftp_port%5D=21&jform%5Bftp_user%5D=&jform%5Bftp_pass%5D=&jform%5Bftp_root%5D=&jform%5Bdbtype%5D=mysqli&jform%5Bhost%5D=localhost&jform%5Buser%5D=testEncrosRC&jform%5Bdb%5D=testEncros&jform%5Bdbprefix%5D=mj_&jform%5Bmailer%5D=mail&jform%5Bmailfrom%5D=sandeep.s%40raincreatives.com&jform%5Bfromname%5D=Test&jform%5Bsendmail%5D=%2Fusr%2Fsbin%2Fsendmail&jform%5Bsmtpauth%5D=0&jform%5Bsmtpsecure%5D=none&jform%5Bsmtpport%5D=25&jform%5Bsmtpuser%5D=&jform%5Bsmtppass%5D=&jform%5Bsmtphost%5D=localhost&jform%5Brules%5D%5Bcore.login.site%5D%5B1%5D=&jform%5Brules%5D%5Bcore.login.admin%5D%5B1%5D=&jform%5Brules%5D%5Bcore.login.offline%5D%5B1%5D=&jform%5Brules%5D%5Bcore.admin%5D%5B1%5D=&jform%5Brules%5D%5Bcore.manage%5D%5B1%5D=&jform%5Brules%5D%5Bcore.create%5D%5B1%5D=&jform%5Brules%5D%5Bcore.delete%5D%5B1%5D=&jform%5Brules%5D%5Bcore.edit%5D%5B1%5D=&jform%5Brules%5D%5Bcore.edit.state%5D%5B1%5D=&jform%5Brules%5D%5Bcore.edit.own%5D%5B1%5D=&jform%5Brules%5D%5Bcore.login.site%5D%5B6%5D=1&jform%5Brules%5D%5Bcore.login.admin%5D%5B6%5D=1&jform%5Brules%5D%5Bcore.login.offline%5D%5B6%5D=1&jform%5Brules%5D%5Bcore.admin%5D%5B6%5D=&jform%5Brules%5D%5Bcore.manage%5D%5B6%5D=&jform%5Brules%5D%5Bcore.create%5D%5B6%5D=1&jform%5Brules%5D%5Bcore.delete%5D%5B6%5D=1&jform%5Brules%5D%5Bcore.edit%5D%5B6%5D=1&jform%5Brules%5D%5Bcore.edit.state%5D%5B6%5D=1&jform%5Brules%5D%5Bcore.edit.own%5D%5B6%5D=1&jform%5Brules%5D%5Bcore.login.site%5D%5B7%5D=&jform%5Brules%5D%5Bcore.login.admin%5D%5B7%5D=&jform%5Brules%5D%5Bcore.login.offline%5D%5B7%5D=&jform%5Brules%5D%5Bcore.admin%5D%5B7%5D=&jform%5Brules%5D%5Bcore.manage%5D%5B7%5D=1&jform%5Brules%5D%5Bcore.create%5D%5B7%5D=&jform%5Brules%5D%5Bcore.delete%5D%5B7%5D=&jform%5Brules%5D%5Bcore.edit%5D%5B7%5D=&jform%5Brules%5D%5Bcore.edit.state%5D%5B7%5D=&jform%5Brules%5D%5Bcore.edit.own%5D%5B7%5D=&jform%5Brules%5D%5Bcore.login.site%5D%5B2%5D=1&jform%5Brules%5D%5Bcore.login.admin%5D%5B2%5D=&jform%5Brules%5D%5Bcore.login.offline%5D%5B2%5D=&jform%5Brules%5D%5Bcore.admin%5D%5B2%5D=&jform%5Brules%5D%5Bcore.manage%5D%5B2%5D=&jform%5Brules%5D%5Bcore.create%5D%5B2%5D=&jform%5Brules%5D%5Bcore.delete%5D%5B2%5D=&jform%5Brules%5D%5Bcore.edit%5D%5B2%5D=&jform%5Brules%5D%5Bcore.edit.state%5D%5B2%5D=&jform%5Brules%5D%5Bcore.edit.own%5D%5B2%5D=&jform%5Brules%5D%5Bcore.login.site%5D%5B3%5D=&jform%5Brules%5D%5Bcore.login.admin%5D%5B3%5D=&jform%5Brules%5D%5Bcore.login.offline%5D%5B3%5D=&jform%5Brules%5D%5Bcore.admin%5D%5B3%5D=&jform%5Brules%5D%5Bcore.manage%5D%5B3%5D=&jform%5Brules%5D%5Bcore.create%5D%5B3%5D=1&jform%5Brules%5D%5Bcore.delete%5D%5B3%5D=&jform%5Brules%5D%5Bcore.edit%5D%5B3%5D=&jform%5Brules%5D%5Bcore.edit.state%5D%5B3%5D=&jform%5Brules%5D%5Bcore.edit.own%5D%5B3%5D=1&jform%5Brules%5D%5Bcore.login.site%5D%5B4%5D=&jform%5Brules%5D%5Bcore.login.admin%5D%5B4%5D=&jform%5Brules%5D%5Bcore.login.offline%5D%5B4%5D=&jform%5Brules%5D%5Bcore.admin%5D%5B4%5D=&jform%5Brules%5D%5Bcore.manage%5D%5B4%5D=&jform%5Brules%5D%5Bcore.create%5D%5B4%5D=&jform%5Brules%5D%5Bcore.delete%5D%5B4%5D=&jform%5Brules%5D%5Bcore.edit%5D%5B4%5D=1&jform%5Brules%5D%5Bcore.edit.state%5D%5B4%5D=&jform%5Brules%5D%5Bcore.edit.own%5D%5B4%5D=&jform%5Brules%5D%5Bcore.login.site%5D%5B5%5D=&jform%5Brules%5D%5Bcore.login.admin%5D%5B5%5D=&jform%5Brules%5D%5Bcore.login.offline%5D%5B5%5D=&jform%5Brules%5D%5Bcore.admin%5D%5B5%5D=&jform%5Brules%5D%5Bcore.manage%5D%5B5%5D=&jform%5Brules%5D%5Bcore.create%5D%5B5%5D=&jform%5Brules%5D%5Bcore.delete%5D%5B5%5D=&jform%5Brules%5D%5Bcore.edit%5D%5B5%5D=&jform%5Brules%5D%5Bcore.edit.state%5D%5B5%5D=1&jform%5Brules%5D%5Bcore.edit.own%5D%5B5%5D=&jform%5Brules%5D%5Bcore.login.site%5D%5B8%5D=&jform%5Brules%5D%5Bcore.login.admin%5D%5B8%5D=&jform%5Brules%5D%5Bcore.login.offline%5D%5B8%5D=&jform%5Brules%5D%5Bcore.admin%5D%5B8%5D=1&jform%5Brules%5D%5Bcore.manage%5D%5B8%5D=&jform%5Brules%5D%5Bcore.create%5D%5B8%5D=&jform%5Brules%5D%5Bcore.delete%5D%5B8%5D=&jform%5Brules%5D%5Bcore.edit%5D%5B8%5D=&jform%5Brules%5D%5Bcore.edit.state%5D%5B8%5D=&jform%5Brules%5D%5Bcore.edit.own%5D%5B8%5D=&jform%5Bfilters%5D%5B1%5D%5Bfilter_type%5D=NH&jform%5Bfilters%5D%5B1%5D%5Bfilter_tags%5D=&jform%5Bfilters%5D%5B1%5D%5Bfilter_attributes%5D=&jform%5Bfilters%5D%5B6%5D%5Bfilter_type%5D=BL&jform%5Bfilters%5D%5B6%5D%5Bfilter_tags%5D=&jform%5Bfilters%5D%5B6%5D%5Bfilter_attributes%5D=&jform%5Bfilters%5D%5B7%5D%5Bfilter_type%5D=NONE&jform%5Bfilters%5D%5B7%5D%5Bfilter_tags%5D=&jform%5Bfilters%5D%5B7%5D%5Bfilter_attributes%5D=&jform%5Bfilters%5D%5B2%5D%5Bfilter_type%5D=NH&jform%5Bfilters%5D%5B2%5D%5Bfilter_tags%5D=&jform%5Bfilters%5D%5B2%5D%5Bfilter_attributes%5D=&jform%5Bfilters%5D%5B3%5D%5Bfilter_type%5D=BL&jform%5Bfilters%5D%5B3%5D%5Bfilter_tags%5D=&jform%5Bfilters%5D%5B3%5D%5Bfilter_attributes%5D=&jform%5Bfilters%5D%5B4%5D%5Bfilter_type%5D=BL&jform%5Bfilters%5D%5B4%5D%5Bfilter_tags%5D=&jform%5Bfilters%5D%5B4%5D%5Bfilter_attributes%5D=&jform%5Bfilters%5D%5B5%5D%5Bfilter_type%5D=BL&jform%5Bfilters%5D%5B5%5D%5Bfilter_tags%5D=&jform%5Bfilters%5D%5B5%5D%5Bfilter_attributes%5D=&jform%5Bfilters%5D%5B8%5D%5Bfilter_type%5D=NONE&jform%5Bfilters%5D%5B8%5D%5Bfilter_tags%5D=&jform%5Bfilters%5D%5B8%5D%5Bfilter_attributes%5D=&task=application.apply&9df64a24b7288428c3919d02fb00848e=1"
-----------------------
array(4) {
["jform"]=>
string(18) "/usr/sbin/sendmail"
["task"]=>
string(5) "apply"
["9df64a24b7288428c3919d02fb00848e"]=>
string(1) "1"
["option"]=>
string(10) "com_config"
}