Home > Backend Development > PHP Tutorial > 微信开发的对象问题

微信开发的对象问题

WBOY
Release: 2016-06-23 13:16:28
Original
1032 people have browsed it


<?phpfunction grade($td_array){    shuffle($td_array);    foreach($td_array as $v){    echo "课程:".$v[0];    $score=$v[1];        switch($score)           {             case $score>=90 && $score<=100:             echo " 绩点:4.0  成绩:".$score." <br>";             break;             case $score>=80 && $score<90:             echo  " 绩点:3.0  成绩:".$score." <br>";             break;             case $score>=70 && $score<80:             echo " 绩点:2.0  成绩:".$score." <br>";             break;             case $score>=60 && $score<70:             echo " 绩点:1.0  成绩:".$score." <br>";             break;             case $score>=0 && $score<60:             echo " 绩点:0.0  成绩:".$score." <br>";             break;             default:             echo $score;          }	}    return ;}		$table =" Array ( [0] => 商务英语听说{td}90{td}2.0{td} [1] => 形势与政策(八){td}70{td}0.5{td} [2] => 积极心态训练{td}89{td}1.0{td} [3] => 欧洲旅游产品设计与营销{td}76{td}2.0{td} )";		array_pop($table);		foreach ($table as $key=>$tr) {			$td = explode('{td}', $tr);			array_pop($td);			$td_array[] = $td;            }$grade=grade($td_array);print_r ($grade);
Copy after login


上面这一段代码是可以输出
但是放在了微信上就不能输出了!输出是空白的
private function grade($td_array){    shuffle($td_array);    foreach($td_array as $v){    echo "课程:".$v[0];    $score=$v[1];        switch($score)           {             case $score>=90 && $score<=100:             echo " 绩点:4.0  成绩:".$score." <br>";             break;             case $score>=80 && $score<90:             echo  " 绩点:3.0  成绩:".$score." <br>";             break;             case $score>=70 && $score<80:             echo " 绩点:2.0  成绩:".$score." <br>";             break;             case $score>=60 && $score<70:             echo " 绩点:1.0  成绩:".$score." <br>";             break;             case $score>=0 && $score<60:             echo " 绩点:0.0  成绩:".$score." <br>";             break;             default:             echo $score;          }	}    return ;   }            public function responseMsg()    {        $postStr = $GLOBALS["HTTP_RAW_POST_DATA"];        if (!empty($postStr)){            $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);            $fromUsername = $postObj->FromUserName;            $toUsername = $postObj->ToUserName;            $keyword = trim($postObj->Content);            $time = time();		$picTpl = "<xml>                        <ToUserName><![CDATA[".$fromUsername."]]></ToUserName>                        <FromUserName><![CDATA[".$toUsername."]]></FromUserName>                        <CreateTime>".$time."</CreateTime>                        <MsgType><![CDATA[news]]></MsgType>                        <ArticleCount>1</ArticleCount>                        <Articles>                        <item>						<Title><![CDATA[%s]]></Title>						<Description><![CDATA[%s]]></Description>						<PicUrl><![CDATA[]]></PicUrl>						<Url><![CDATA[]]></Url>						</item>                        </Articles>                        <FuncFlag>1</FuncFlag>                        </xml>";		            if(!empty( $keyword ))            {               		        $table = "Array ( [0] => 商务英语听说{td}90{td}2.0{td} [1] => 形势与政策(八){td}70{td}0.5{td} [2] => 积极心态训练{td}89{td}1.0{td} [3] => 欧洲旅游产品设计与营销{td}76{td}2.0{td} )";		        array_pop($table);		        foreach ($table as $key=>$tr) {			        $td = explode('{td}', $tr);			         array_pop($td);			        $td_array[] = $td;                }               $content=$this->grade($td_array);                               $title ="123";                                 $resultStr = sprintf ( $picTpl,$title,$content);                echo $resultStr;            }        }else{            echo "";            exit;        }    }
Copy after login


回复讨论(解决方案)

你自己模拟微信请求下面的逻辑,看看输出什么?
多做些记录

你自己模拟微信请求下面的逻辑,看看输出什么?
多做些记录



输出是空白的,就是在对象$content=$this->grade($td_array)这里出错了,就是想不明白哪里出错
responseMsg()里面用$content=$this->grade($td_array)就输出空白了!
不用responseMsg()这个对象是可以输出的
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template