卓越飞翔博客卓越飞翔博客

卓越飞翔 - 您值得收藏的技术分享站
技术文章1829本站已运行4109

帝国常用的PHP判断语法集合

默认内容页帝国CMS推论方法

<?php
if($navinfor[befrom]){
?>

来源:[!--befrom--]

<?php }?>

利用PHP语法输出推论结果

<?php
if($navinfor[befrom]){
echo"来源:".$navinfor[befrom];
}?>
<?phpif($navinfor[befrom]){
echo"来源:".ReplaceBefrom($navinfor[befrom]);
}
?>

融合if else来使用

<?php
if($navinfor['befrom']){
?>

[!--befrom--]

<?php }else{ ?> 大众资源网 <?php }?>

emptye的方法

<?php if(!empty($classr[classimg])){ 
echo ''; 
}else{ 
echo '';
 } 
?>

注解:!(为不能)+empty(为空)=!empty(不为空)
各种判断调用作者的方法

<?=ReplaceBefrom($navinfor[befrom]?$navinfor[befrom]:'大众资源网')?>
<?=$navinfor[befrom]?'来源:'.$navinfor[befrom].'':''?>
<?=$navinfor[befrom]?"来源:$navinfor[befrom]  ":""?>  注解:  为空格
<?=$navinfor[befrom]?$navinfor[befrom]:"暂无简介  "?>
<? echo  $navinfor['befrom']?'来源:'.$navinfor[befrom].'':'尚无来源';?>
<?=$navinfor[writer]?:"暂"?>

switch推论方法

<?php
switch($class_r[$GLOBALS[navclassid]]['bname']){
case "国内":
$sid = 34;
break;
case "国际":
$sid = 35;
break;
default:
$sid = 34;
}
?>
<?=$sid?>

包括多值时的推论

<?php
$c1_r=array(35,34);
$c2_r=array(36,37);
if(in_array($GLOBALS[navclassid],$c1_r)){
$cid1='广告1';
}elseif(in_array($GLOBALS[navclassid],$c2_r)){
$cid1='广告2';
}else{
$cid1='其他广告';
}?>
<?=$cid1?>

或轻易输入:把 $cid1 =  改成 echo

卓越飞翔博客
上一篇: php获取帝国CMS各种路径的几种方法
下一篇: 帝国CMS模制作常用调用标签收藏
留言与评论(共有 0 条评论)
   
验证码:
隐藏边栏