notice:undefined index:http_raw_post_data in D:program Files appears in PHP

Source: Internet
Author: User
Tags cdata
I wrote it in PHP:

$POSTSTR = $GLOBALS ["Http_raw_post_data"];
After running
notice:undefined Index:http_raw_post_data in D:\Program files\phpenv\phpdemo\shm_php01\shm01.php on line 47 appears in PHP

Then I removed the Always_populate_raw_post_data = on comment from the php.ini file.

; Always populate the $HTTP _raw_post_data variable. PHP ' s default behavior is
; To disable this feature. If post reading is disabled through
; Enable_post_data_reading, $HTTP _raw_post_data is *not* populated.
; Http://php.net/always-populate-raw-post-data
Always_populate_raw_post_data = On

Restart is still not used, ask the man to guide the maze


Reply to discussion (solution)

Always_populate_raw_post_data = On

When submitted as post, available
echo $HTTP _raw_post_data;
Print out the submitted unformatted string.

Of course not when the post is submitted, it is undefined

Actually, this could have been replaced with file_get_contents (' Php://input ').

Always_populate_raw_post_data = On

When submitted as post, available
echo $HTTP _raw_post_data;
Print out the submitted unformatted string.

Of course not when the post is submitted, it is undefined



My source code method is this:
Public Function responsemsg ()
{
$POSTSTR = $GLOBALS ["Http_raw_post_data"];

if (!empty ($POSTSTR)) {
$POSTOBJ = simplexml_load_string ($HTTP _raw_post_data, ' simplexmlelement ', libxml_nocdata);
$fromUsername = $POSTOBJ->fromusername;
$toUsername = $POSTOBJ->tousername;
$keyword = Trim ($postObj->content);
$time = time ();
$TEXTTPL = "
%s
%s
%s
%s
%s
0
";
if ($keyword = = "?" | | $keyword = = "? ")
{
$msgType = "text";
$CONTENTSTR = Date ("Y-m-d h:i:s", Time ());
$RESULTSTR = sprintf ($TEXTTPL, $fromUsername, $toUsername, $time, $msgType, $CONTENTSTR);
Echo $resultStr;
}
}else{
echo "";
Exit
}
}

Help me look.

Public Function responsemsg () {
if (! isset ($GLOBALS ["Http_raw_post_data"])) return ';
$POSTSTR = $GLOBALS ["Http_raw_post_data"];

Public Function responsemsg () {
if (! isset ($GLOBALS ["Http_raw_post_data"])) return ';
$POSTSTR = $GLOBALS ["Http_raw_post_data"];



I tried it this way, so I return directly. Then the following code is not implemented: I don't know.

Direct run, of course, is to return directly
If post is submitted, it will be.

Direct run, of course, is to return directly
If post is submitted, it will be.



Maybe I'm not very good, so I'm learning, thank you.

You have to write a form when you test.

This is the code inside the interface I also appeared this problem landlord solved it

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.