一、基本用法:
{dede:field.descriptionrunphp='yes'}
if(@me<>'' )
@me = '<div class="intro">'.@me.'</div>';
{/dede:field.description}
{dede:field name='imgurls' alt='图片输出区'}
[field:pagestylerunphp='yes'] @me= (@me==3 ? '<li>' : '');[/field:pagestyle]
<a href='[field:linkurl/]' [field:pagestyle runphp='yes'] @me= (@me==3 ? 'class="pic"' : ''); [/field:pagestyle]>
<img src='[field:imgsrc/]' id='bigimg' [field:imgwidth /] alt='[field:alttext /]' border='0' />
</a>
<a href='[field:linkurl/]' [field:pagestyle runphp='yes']@me = (@me==3 ? 'class="title"' : '');[/field:pagestyle]>
[field:title /]
</a>
[field:pagestyle runphp='yes'] @me = (@me==3 ? '</li>' : ''); [/field:pagestyle]
{/dede:field}二、高级用法:
1、dede后台-youjiankuohaophpcn系统->系统设置->系统基本参数->其它选项->把“模板引擎禁用标签”中的"php"标签去掉,保存
2、使用:
{dede:php}
echo 'php';
{/dede:php}
{dede:php}
$result = mysql_query("select * from bbs_forum_forum t1 left join bbs_forum_forumfield t2 on t1.fid=t2.fid where status=1 and 
type='forum' order by t1.displayorder asc");
while($row = mysql_fetch_assoc($result)){
     echo '<table cellpadding="0" cellspacing="0" width="100%" border="0" class="pbw_bbsTable">';
     echo '<tr>';
     echo '<td width="64">';
     echo '<a href="/bbs/forum.php?mod=forumdisplay&fid='.$row['fid'].'">
     <img src="/bbs/data/attachment/common/'.$row['icon'].'" width="46" height="46" style="border:1px solid #000;" /></a>';
     echo '</td>';
     echo '<td width="465">';
     echo '<div class="pbw_bbsTitle"><a href="/bbs/forum.php?mod=forumdisplay&fid='.$row['fid'].'">'.$row['name'].'</a><span>('.$row['threads'].')</span></div>';
     echo '<div class="pbw_bbsBrief">'.$row['description'].'</div>';
     echo '<div style="color:red;">'.$row['rules'].'</div>';
     $moderators = explode("    ", $row['moderators']);
     $moderators = implode(",", $moderators);
     echo '<div class="pbw_bbsBanzhu">版主:'.$moderators.'</div>';
     echo '</td>';
     echo '<td width="90"> </td>';
     echo '<td width="120" align="center">';
     echo $row['threads'].'/'.$row['posts'];
     echo '</td>';
     echo '<td>';
     $lastpost = explode("    ", $row['lastpost']);
     echo '<a href="/bbs/forum.php?mod=viewthread&tid='.$lastpost[0].'#lastpost">'.$lastpost[1].'</a>
     (<a href="/bbs/home.php?mod=space&username='.$lastpost[3].'" style="color:#369">'.$lastpost[3].'</a>)<br />';
     echo date("Y-m-d H:i:s", $lastpost[2]);
     echo '</td>';
     echo '</tr>';
     echo '</table>';
}
{/dede:php}以上就是在Dede中如何使用PHP的示例代码分享的详细内容,更多请关注php中文网其它相关文章!
                        
                        PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
                Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号