Introduction: This is a detailed page that does not include nested ifesle in ifelse. It introduces PHP, related knowledge, skills, experience, and some PHP source code.
Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 333684 'rolling = 'no'>
I have been scolded for secondary development.CodeSo in order to avoid being scolded, I tried to write comments and found that the Code is even more messy when the comments are added. Today, I reviewed a function code review and summarized a previous experience: Try not to nest ifelse in ifelse.
Next, paste the code for comparison.
Before code review:
/*** Get user information ** @ return link is the invitation link, * score is the point, * nick is the nickname, * num is the number of works, and thus the number of pages is determined, * opus1 is the first work image on the current page, * opus2 is the second work image address on the current page, * opus3 is the third work on the current page */Public Function uinfoaction () {$ random = $ this-> request-> getgetparameter ('random '); // random number $ Pwd = $ this-> request-> getgetparameter ('pwd '); // Private Key // $ page = $ this-> request-> getgetparameter ('page', 1 ); // current page // verify that the flash request is correct if ($ Pwd = MD5 ("tenwowactqqcom @ tenwow123 ". $ random) {// verify Q Q: log on to If (tmauthutils: islogin () {$ QQ = tmauthutils: getuin (); $ link = tmlibhtmlhelper: urljump (tmconfig: base_url, $ QQ, 1, tmconfig: tams_id); // invite a friend Link $ service = new tmservice (); $ info = $ service-> selectone (Array ('fqq' => $ qq), 'fscorecount, fnick ', 'tbl _ user '); // obtain the nickname // The Flash party requires that all data be obtained/* $ number = ($ page-1) * 3; $ COUNT = count ($ service-> select (Array ("fqq" => $ qq), '*', 'tbl _ file ')); $ list = $ service-> select (Array ("fqq" => $ Qq), "Furl", 'tbl _ file', array ($ number, 3), array ('orderby' => 'ffileid DESC ')); * // judge whether $ list is empty $ COUNT = count ($ service-> select (Array ("fqq" => $ qq ),'*', 'tbl _ file'); $ list = $ service-> select (Array ("fqq" => $ qq), "Furl", 'tbl _ file '); $ PIC = array (); // image address array foreach ($ list as $ Li) {$ Li [0] = tmconfig: base_url. "Data /". $ Li [0]; $ PIC [] = $ Li [0];} return json_encode (Array ('code' => '0 ', 'message' => 'data pulled successfully ', 'qq' => "$ QQ", 'lin K' => $ link, 'score '=> $ info ['fscorecount'], 'Nick' => $ info ['fnick '], 'wblog' => "1000", 'num' => "$ count", 'pic '=> $ pic ,));} else {return json_encode (Array ("code" => '1', 'message' => 'sorry, you have not logged on! ');} // Endif verify whether QQ is logged on} else {return json_encode (Array ("code" => '2 ', 'message' => 'Please participate in the game from the valid link! ');} // Endif verify that the flash request is correct}
After code review:
/*** Get user information ** @ return code string return information code * message string return information * QQ string user QQ * link string the link for inviting friends to participate in the activity * score string the current number of points * nick string user nickname * wblog string microblog followers * num string current number of files * PIC array file address */Public Function uinfoaction () {$ random = $ this-> request-> getgetparameter ('random '); // random number $ Pwd = $ this-> request-> getgetparameter ("PWD "); // Private Key // determine whether to participate in the game from a valid link if ($ PWD! = MD5 ("tenwowactqqcom @ tenwow123 ". $ random) {return json_encode (Array ("code" => "2", "message" => "please join the game from a valid link! ");} // Determine whether to log on if (! Tmauthutils: islogin () {return json_encode (Array ("code" => "1", "message" => "Sorry, you have not logged on! ") ;}$ QQ = tmauthutils: getuin (); // get logon QQ $ link = tmlibhtmlhelper: urljump (tmconfig: base_url, $ QQ, 1, tmconfig:: tams_id); // get the invitation link $ service = new tmservice (); // create an object for operation data $ info = $ service-> selectone (Array ("fqq" => $ qq), "fscorecount, fnick", "tbl_user "); // obtain the logon QQ nickname, Activity points $ piccount = count ($ service-> select (Array ("fqq" => $ qq), "Furl ", "tbl_file"); // get the current number of files $ PIC = array (); // initialize the image address array $ list = $ service-> select (Array ("fqq" => $ qq), "Furl", "tbl_file "); // obtain the image address // because select queries a two-dimensional array, you need to put it into $ PIC foreach ($ list as $ Li) {$ PIC [] = tmconfig:: base_url. "Data /". $ Li [0];} // ----------- and wblogreturn json_encode (Array ("code" => "0 ", "Message" => "Data pulled successfully", "QQ" => "{$ QQ}", "Link" => "{$ link }", "score" => "{$ info ['fscorecount']}", "Nick" => "{$ info ['fnick ']}", "wblog" => "100000", "num" => "{$ piccount}", "pic" => "{$ PIC }"));}
The effect is obvious.
More articles about "do not nest ifesle in ifelse"
Love J2EE follow Java Michael Jackson video station JSON online tools
Http://biancheng.dnbcw.info/php/333684.html pageno: 11.