PHP代码部分不是很清楚 高手求解,求理解 5
<?phpsession_start();header("Content-type:text/html;charset=UTF-8");//设置文件编码格式require...
<?php
session_start();
header ( "Content-type: text/html; charset=UTF-8" ); //设置文件编码格式
require("system/system.inc.php"); //包含配置文件
$reback = '0';
$commid = explode(',',$_GET['rd']);
$newshop = array();
$sql = "select id,shopping from tb_user where name = '".$_SESSION['member']."'";
$rst = $admindb->ExecSQL($sql,$conn);
if($rst==false){
$reback = '2';
}else{
if(!empty($rst[0]['shopping'])){
$tmpshop = array();
$shopping = explode('@',$rst[0]['shopping']);
foreach($shopping as $ky => $vl){
$tmp = explode(',',$vl);
$boo = false;
foreach($commid as $value){
if($value == $tmp[0]){
$boo = true;
}
}
if(!$boo){
$tmpshop[$ky] = $vl;
}
}
if(!empty($tmpshop)){
$update = "update tb_user set shopping='".implode('@',$tmpshop)."' where name = '".$_SESSION['member']."'";
}else{
$update = "update tb_user set shopping='' where name = '".$_SESSION['member']."'";
}
$shop = $admindb->ExecSQL($update,$conn);
if($shop){
$reback = 1;
}else{
$reback = 3;
}
}
}
echo $reback;
?>
这部分怎么解释
f(!empty($rst[0]['shopping'])){
$tmpshop = array();
$shopping = explode('@',$rst[0]['shopping']);
foreach($shopping as $ky => $vl){怎么解释
$tmp = explode(',',$vl);怎么解释
$boo = false;怎么解释
foreach($commid as $value){
if($value == $tmp[0]){怎么解释
$boo = true;怎么解释}
}
if(!$boo){怎么解释
$tmpshop[$ky] = $vl;怎么解释
}
if(!empty($tmpshop)){
$update = "update tb_user set shopping='".implode('@',$tmpshop)."' where name = '".$_SESSION['member']."'";这部分怎么解释 展开
session_start();
header ( "Content-type: text/html; charset=UTF-8" ); //设置文件编码格式
require("system/system.inc.php"); //包含配置文件
$reback = '0';
$commid = explode(',',$_GET['rd']);
$newshop = array();
$sql = "select id,shopping from tb_user where name = '".$_SESSION['member']."'";
$rst = $admindb->ExecSQL($sql,$conn);
if($rst==false){
$reback = '2';
}else{
if(!empty($rst[0]['shopping'])){
$tmpshop = array();
$shopping = explode('@',$rst[0]['shopping']);
foreach($shopping as $ky => $vl){
$tmp = explode(',',$vl);
$boo = false;
foreach($commid as $value){
if($value == $tmp[0]){
$boo = true;
}
}
if(!$boo){
$tmpshop[$ky] = $vl;
}
}
if(!empty($tmpshop)){
$update = "update tb_user set shopping='".implode('@',$tmpshop)."' where name = '".$_SESSION['member']."'";
}else{
$update = "update tb_user set shopping='' where name = '".$_SESSION['member']."'";
}
$shop = $admindb->ExecSQL($update,$conn);
if($shop){
$reback = 1;
}else{
$reback = 3;
}
}
}
echo $reback;
?>
这部分怎么解释
f(!empty($rst[0]['shopping'])){
$tmpshop = array();
$shopping = explode('@',$rst[0]['shopping']);
foreach($shopping as $ky => $vl){怎么解释
$tmp = explode(',',$vl);怎么解释
$boo = false;怎么解释
foreach($commid as $value){
if($value == $tmp[0]){怎么解释
$boo = true;怎么解释}
}
if(!$boo){怎么解释
$tmpshop[$ky] = $vl;怎么解释
}
if(!empty($tmpshop)){
$update = "update tb_user set shopping='".implode('@',$tmpshop)."' where name = '".$_SESSION['member']."'";这部分怎么解释 展开
展开全部
简单给你说一下
empty()函数,检测变量是否为空,是空就返回true,否则返回false
foreach循环,遍历一个数组
explode()函数,将字符串以特定的分隔符打散成数组
if语句,对特定的条件进行判断
!感叹号,表示否定,相反的意思
[]方括号,对数组元素的访问
implode()函数,以特定的字符将数组转换成字符串
建议你还是从php最基本的开始学起吧,看你的提问,似乎你对php还没有一点基础就来研究成片的代码了,走都不会,咋能飞呢!
比如:php的基本语法、基本函数的应用等等开始学起!
empty()函数,检测变量是否为空,是空就返回true,否则返回false
foreach循环,遍历一个数组
explode()函数,将字符串以特定的分隔符打散成数组
if语句,对特定的条件进行判断
!感叹号,表示否定,相反的意思
[]方括号,对数组元素的访问
implode()函数,以特定的字符将数组转换成字符串
建议你还是从php最基本的开始学起吧,看你的提问,似乎你对php还没有一点基础就来研究成片的代码了,走都不会,咋能飞呢!
比如:php的基本语法、基本函数的应用等等开始学起!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询