1. Error report of chapter and catalog after re collection October 3, 2018
Warning: Invalid argument supplied for foreach() in /usr/share/wwwphp/ptcms/application/novelsearch/model/novelsearch_chapter.php on line 326
<?php $a =&$b ?>vim /usr/share/wwwphp/ptcms/application/novelsearch/model/novelsearch_chapter.php public function getolist($zym_38, $zym_27 = 1, $zym_11 = 0) { $zym_49 = 'chapterolist_' . $zym_38; $zym_52 = $this->cache->get($zym_49); if (APP_DEBUG || !$zym_52) { $this->setTableId($zym_38); if ($zym_11 == 0) { $zym_52 = $this->where(array('novelid' => $zym_38, 'oid' => array('>', 0)))->group('oid')->field('oid,name,time,url,id')->order('oid asc')->select(); } else { $zym_52 = $this->where(array('novelid' => $zym_38, 'oid' => array('>', 0)))->group('oid')->field('oid,name,time,url,id')->order('oid asc')->page($zym_27)->pagesize($zym_11)->select(); } $zym_13 = $this->get('novelsearch_info', $zym_38, 'novel.pinyin'); foreach ($zym_52 as &$zym_47) { $zym_47['url_read'] = U('novelsearch.chapter.read', array('novelid' => $zym_38, 'novelkey' => $zym_13, 'chapterid' => $zym_47['oid'])); } $this->cache->set($zym_49, $zym_52, 900); } return $zym_52; }
This means that $a and $b point to the same variable.
Note: $a and $b are exactly the same here. It's not that $a points to $b or vice versa, but that $a and $b point to the same place
The doubt lies in the quotation.
/* foreach Structure, this is just a simple way to traverse the array. foreach Can only be used for arrays, which can cause errors when trying to use it for other data types or an uninitialized variable. There are two grammars, and the second is a useful extension of the first. foreach(array_expression as $value) statement foreach(array_expression as $key => $value) statement The first format traverses a given array of expressions. In each loop, the value of the current cell is assigned to $value and the pointer inside the array moves one step forward (so the next loop will get the next cell). The second format does the same thing, except that in addition to the value of the current cell, the key value is also assigned to the variable $key in each loop. Look at the following code: $arr = array("1"=>"111","2"=>"222","3"=>"333"); foreach($arr as $key=>$value) { echo $key."=>".$value."\n"; } The results are as follows: 1=>111 2=>222 3=>333 Key value can be understood as array subscript here. The subscript of array element a[2] is 2 When foreach starts executing, the pointer inside the array automatically points to the first cell. This means that reset() does not need to be called before the foreach loop. while loops need reset. The following two code functions are identical. 1.Loop with while $arr = array("one", "two", "three"); reset ($arr); while (list(, $value) = each ($arr)) { echo "Value: $value<br>\n"; } 2.Using foreach foreach ($arr as $value) { echo "Value: $value<br>\n"; } Also note that foreach operates on a copy of the specified array, not the array itself. Therefore, even with the construction of each(), the original array pointer does not change, and the value of the array unit is not affected. foreach The ability to suppress error messages with "@" is not supported. */ /* foreach Use references in. Generally, $arr and $value in foreach($arr as $value) are copies, which are not affected by external factors */ $arr = array(0,1,2,3,4,5); foreach($arr as $value){ $arr = array(); echo $value; }// The result is: 12345 // But if $arr is a reference, the situation is different. Let's use code to explain the problem $arr = array(0,1,2,3,4,5); $arr = &$arr; foreach($arr as $value){ $arr = array(); echo $value; }// The result is: 0 this is because the recycled $arr points directly to the original data, rather than copying a copy. //If $value is a reference, the result is the same, and the same $value points to the original data instead of copy $arr = array(0,1,2,3,4,5); foreach($arr as &$value){ $arr = array(); echo $value; }// The result is: 0 //Another special case is that if $arr is defined as a global variable, $arr will also become a reference global $arr; $arr = array(0,1,2,3,4,5); foreach($arr as $value){ $arr = array(); echo $value; }// The result is: 0 /* If you loop an array twice, you must not write like this foreach($arr as &$value){} foreach($arr as $value){} This will result in incorrect results of the second loop (probably a php bug). It can be replaced by the following: //solution 1 foreach($arr as &$value){} unset($value); foreach($arr as $value){} //solution 2 foreach($arr as &$value){} foreach($arr as &$value){} //solution 3 foreach($arr as &$value){} $arr2 = $arr; foreach($arr2 as $value){} 3.To prevent undefined foreach, try to write foreach in this way foreach((array)$arr as $value) {} */ $test=array('a','b','c'); foreach($test as &$value){ echo $value; } echo $value; foreach($test as $value){ echo $value; } echo $value; /* Operation result: In the first foreach, we use the assignment reference symbol, which means that each time we traverse, $value points to the address of the corresponding element in the $test array, once in the loop, $value points to the address of 'a', the second loop, $test points to the address of the second element 'b', and the third loop points to the address of 'c'. 'a','b','c' $value The variable points to the address of the third element of $test, 'c' 'c' 'a','b','b' 'b' Explanation: Then foreach itself assigns the corresponding elements in the array to the variables after as, so in the second foreach, when traversing for the first time, it assigns' a 'on the first variable address of the array to the address pointed to by $value, i.e., ['a','b','a'], and in the second calendar, it assigns' b 'on the second variable address of the array to the address pointed to by $value, i.e., ['a','b','b'] In the third iteration, assign 'b' on the third variable address of the array to the address pointed to by $value, or ['a','b','b ']. If you still want to ['a','b','a ']: After using the assignment reference operator, unset the variable. unset($value) statement, which is equivalent to dereference of $value to the address, so that the second foreach, $value is equivalent to a new variable. */ $test=array('a','b','c'); foreach($test as &$value){ //Operate on $value } var_dump($test); /* The results are as follows: array(3) { [0]=> string(1) "a" [1]=> string(1) "b" [2]=> &string(1) "c" } //Element 'c' is preceded by an assignment reference '&‘ */
vim /usr/share/wwwphp/ptcms/test.php
After testing, php7.2 can run the above test program.
public function getolist($zym_38, $zym_27 = 1, $zym_11 = 0) { $zym_49 = 'chapterolist_' . $zym_38; $zym_52 = $this->cache->get($zym_49); // echo $zym_52; print_r($zym_49); echo"<br/>";
Print ﹣ no data, print ﹣ no data, Print ﹣ no data, print ﹣ chapterlist ﹣ 34
In the public function getchapterlist ($zym 38, $zym 42, $zym 27, $zym 11)
$zym? 52 = this − gt; where (this - & gt; where (this − > where (zym? 48) - > field ('id,siteid,name,oid,time ') - > page (zym27) - & gt; limit (zym? 27) - & gt; limit (zym2 7) - > limit (zym? 11) - > order ($zym? 51) - > select(); to access data.
In public function getolist ($zym ﹣ 38, $zym ﹣ 27 = 1, $zym ﹣ 11 = 0)
$zym_52 = $this->where(array('novelid' => $zym_38, 'oid' => array('>', 0)))->group('oid')->field('oid,name,time,url,id')->order('oid asc')->select();
Data not retrieved, try to modify
$zym ﹣ 52 = $this - > where (array ('novelid '= > zym ﹣ 38)) - > group ('oid') - > field ('oid,name,time,url,id ') - > order ('oid asc') - > select(); no
$zym ﹣ 52 = $this - > where (array ('novelid '= > zym ﹣ 38)) - > field ('oid,name,time,url,id') - > order ('oid asc ') - > select(); you can
The mistakes are gone, but
It's better
There are no scripts
<script type="text/javascript"> $(function(){$(".g-star").raty({scoreName:"star",score:"20",click:function(v){layer.confirm("Your rating of Shengxu"+v+"branch,Please confirm the operation!",{btn:["determine","give up"]},function(index){$.get("/user/star/add.html",{novelid:"1692",star:v},function(res){if(res.status==1){layer.alert("Scoring successful",{icon:6})}else{if(res.code==-1){layer.alert(res.info,{icon:5},function(){window.location.href=res.data})}else{layer.alert(res.info,{icon:5})}}},"json");layer.close(index)})}});var length=$(".fulldir .dirlist li").length;if(length>30){var len=Math.ceil(length/3);$(".fulldir .dirlist li:lt(15)").removeClass("hide");$(".fulldir .dirlist li:gt("+(3*(len-5)-1)+")").removeClass("hide");$(".fulldir .dirlist li").eq(14).after('<li class="fulltip">···················· View all'+length+"chapter ····················</li>")}else{$(".fulldir .dirlist li").removeClass("hide")}$(".loading").remove();$(".fulltip").on("click",function(){$(this).remove();$(".fulldir .dirlist li").removeClass("hide")});$(".commentlist a").on("click",function(){var param={id:$(this).parent().data("id")},$num=$(this).find("span"),url;if($(this).hasClass("up")){url="/novelsearch/comment/good.html"}else{if($(this).hasClass("down")){url="/novelsearch/comment/bad.html"}else{return true}}$.post(url,param,function(res){if(res.status==1){layer.alert(res.info,{icon:6},function(i){$num.text(parseInt($num.text())+1);layer.close(i)})}else{layer.alert(res.info,{icon:5})}},"json")})}); ;(function(){var ua=navigator.userAgent.toLowerCase();if(/ipad/i.test(ua)||/iphone/i.test(ua)||/windows mobile/i.test(ua)||/android/i.test(ua)){var u="1692/";setTimeout(function(){window.location.href="https://m.kuaiyankanshu.net/"+u},300)}})(); </script>
The basic acquisition display error has been solved; the following is the improvement of acquisition rules and further imitation of the master station