This article gives an example of how the PHP version of the micro-letter returns user text input. Share to everyone for your reference, specific as follows:
Get what the user has entered and return the same content
Get POST data//$PostData = $HTTP _raw_post_data;
$PostData = file_get_contents ("Php://input");
Determines whether the post is an empty if (! $PostData) {echo "wrong input!";
Exit (0);
}//Parse XML string $xmlObj = Simplexml_load_string ($PostData, ' simplexmlelement ', libxml_nocdata);
if (! $xmlObj) {echo "wrong input!";
Exit (0);
}//Get Data $fromUserName = $XMLOBJ->fromusername;
$toUserName = $XMLOBJ->tousername;
$msgType = $XMLOBJ->msgtype; Returns user input if (' text '!= $msgType) {//Not text, output error message $RETMSG = "Only support text message";//user input text else{$content = $XMLOBJ->con
Tent
$RETMSG = $content; //output XML template $retTmp = "<xml> <tousername><! [cdata[%s]]></tousername> <fromusername><! [cdata[%s]]></fromusername> <CreateTime>%s</CreateTime> <msgtype><! [cdata[text]]></msgtype> <content><!
[cdata[%s]]></content> <FuncFlag>0</FuncFlag> </xml> "; Replace the wildcard character in the message $RESULTSTR = SPRintf ($RETTMP, $fromUserName, $toUserName, Time (), $RETMSG);
Message echo for output XML $RESULTSTR
For more information on PHP related content readers can view the site topics: "PHP micro-credit Development Skills summary", "PHP coding and transcoding Operation skills Summary", "PHP Network Programming Skills Summary", "PHP basic Grammar Introductory Course", "PHP string (String) Usage Summary", "php+ MySQL Database operations Introduction tutorial and PHP Common database operation Skills Summary
I hope this article will help you with the PHP program design.