BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / www-technology / #30831同步于 2015/7/23
该镜像源已超过 30 天没有更新,可能在源站已被删除。
WWWTechnology机器人发帖

向大神请教thinkphp中问题

sunnygirl
2015/7/23镜像同步7 回复
在模板中使用switch case标签如下: <td colspan="2" rowspan="4" width="759" height="425"align="center" valign="top"> <switch name="Think.get.type_link"> <case value="data" break="1"><include file="./Admin/Tpl/Index/data.html"/> </case> <default/><include file="./Admin/Tpl/Index/data.html"/> </switch> </td> 可是有错错误如下: :( syntax error, unexpected T_INLINE_HTML, expecting T_ENDSWITCH or T_CASE or T_DEFAULT 错误位置 FILE: C:\AppServ\www\24\Admin\Runtime\Cache\1515bbcb74458660b6f7eae0d79dd3e5.php LINE: 80 ThinkPHP3.1.3 { Fast & Simple OOP PHP Framework } -- [ WE CAN DO IT JUST THINK ] 请指教,谢谢
订阅后,新回复会通过你的通知中心匿名送达。
7 条回复
vampire24机器人#1 · 2015/7/24
开发的时候把缓存关掉 【 在 sunnygirl 的大作中提到: 】 在模板中使用switch case标签如下: <td ...
zzjin机器人#2 · 2015/7/24
打开C:\AppServ\www\24\Admin\Runtime\Cache\1515bbcb74458660b6f7eae0d79dd3e5.php 这个文件看一下具体的编译后的源码怎么写的吧
sunnygirl机器人#3 · 2015/7/24
【 在 zzjin 的大作中提到: 】 : 打开C:\AppServ\www\24\Admin\Runtime\Cache\1515bbcb74458660b6f7eae0d79dd3e5.php 这个文件看一下具体的编译后的源码怎么写的吧 <td width="559" align="left" > <select name="middleid" id="middleid" > <option selected="selected">请选择</option> <?php if(is_array($data2)): foreach($data2 as $key=>$result2): ?><option value="<?php echo ($result2["id"]); ?>"><?php echo ($result2["ChineseName"]); ?></option><?php endforeach; endif; ?> </select> <select name="elementaryid" id="elementaryid" > <option selected="selected">请选择</option> <?php if(is_array($data3)): foreach($data3 as $key=>$result3): ?><option value="<?php echo ($result3["id"]); ?>"><?php echo ($result3["ChineseName"]); ?></option><?php endforeach; endif; ?> 80行左右就是这样的,谢谢
zzjin机器人#4 · 2015/7/24
只看这一段没问题.能贴一下tpl完整的吗
sunnygirl机器人#5 · 2015/7/25
【 在 zzjin 的大作中提到: 】 : 只看这一段没问题.能贴一下tpl完整的吗 <switch name="Think.get.handle"> <case value="insert"> <form name="form1" method="post" action="__URL__/common?type_link=data&handle=insert"> <table width="750" border="1" cellspacing="1" cellpadding="1"> <tr> <td colspan="2" align="center">数据添加</td> </tr> <tr> <td width="178" align="right">类别选择</td> <td width="559" align="left" > <select name="middleid" id="middleid" > <option selected="selected">请选择</option> <foreach name="data2" item="result2" > <option value="{$result2.id}">{$result2.ChineseName}</option> </foreach> </select> <select name="elementaryid" id="elementaryid" > <option selected="selected">请选择</option> <foreach name="data3" item="result3" > <option value="{$result3.id}">{$result3.ChineseName}</option> </foreach> </select> <select name="smallid" id="smallid" > <option selected="selected">请选择</option> <foreach name="data4" item="result4" > <option value="{$result4.id}">{$result4.ChineseName}</option> </foreach> </select>*请选择其中一项类别 </td> </tr> <tr> <td align="right">名称</td> <td align="left"><input name="title" type="text" id="title" size="40"></td> </tr> <tr> <td align="right">链接地址</td> <td align="left"><input name="href" type="text" id="href" size="40"></td> </tr> <tr> <td align="center">&nbsp;</td> <td><input type="submit" name="button" id="button" value="提交"> &nbsp;&nbsp;&nbsp;&nbsp; <input type="reset" name="button2" id="button2" value="重置"></td> </tr> </table> </form> </case> <case value="admin"> <table width="750" border="1" cellspacing="1" cellpadding="1"> <tr> <td>ID</td> <td>名称</td> <td>链接地址</td> <td>所属类别</td> <td>操作</td> </tr> <foreach name="list" item="result" > <tr> <td>{$result.id}</td> <td>{$result.title}</td> <td>{$result.href}</td> <td> <if condition="($result.middleid neq 0 ) and ($result.elementaryid neq 0) and ($result.smallid neq 0 )"> 中级类别/初级类别/子类别 <elseif condition="($result.middleid neq 0 ) and ($result.elementaryid neq 0)" /> 中级类别/初级类别 <elseif condition="($result.elementaryid neq 0) and ($result.smallid neq 0)" /> 初级类别/子类别 <elseif condition="($result.middleid neq 0 ) and ($result.smallid neq 0)" /> 中级类别/子类别 <elseif condition="$result.middleid neq 0 " /> 中级类别 <elseif condition="$result.elementaryid neq 0 " /> 初级类别 <else /> 子类别 </if> </td> <td><a href="__URL__/deletedata?type_link=data&handle=admin&link_id={$result.id}">删除</a></td> </tr> </foreach> <tr> <td colspan="5">{$page}</td> </tr> </table> </case> <default /> <table width="750" border="1" cellspacing="1" cellpadding="1"> <tr> <td>ID</td> <td>名称</td> <td>链接地址</td> <td>所属类别</td> <td>操作</td> </tr> <foreach name="list" item="result" > <tr> <td>{$result.id}</td> <td>{$result.title}</td> <td>{$result.href}</td> <td> <if condition="($result.middleid neq 0 ) and ($result.elementaryid neq 0) and ($result.smallid neq 0 )"> 中级类别/初级类别/子类别 <elseif condition="($result.middleid neq 0 ) and ($result.elementaryid neq 0)" /> 中级类别/初级类别 <elseif condition="$result.middleid neq 0 " /> 中级类别 <else /> 子类别 </if> </td> <td><a href="__URL__/deletedata?type_link=data&handle=admin&link_id={$result.id}">删除</a></td> </tr> </foreach> <tr> <td colspan="5">{$page}</td> </tr> </table> </switch> 这个是完整的data.html谢谢
zzjin机器人#6 · 2015/7/27
上面的代码我本地运行没问题啊,编译之后的纯php代码: <?php if (!defined('THINK_PATH')) exit();?><?php switch($_GET['handle']): ?><?php case "insert": ?><form name="form1" method="post" action="__URL__/common?type_link=data&handle=insert"> <table width="750" border="1" cellspacing="1" cellpadding="1"> <tr> <td colspan="2" align="center">数据添加</td> </tr> <tr> <td width="178" align="right">类别选择</td> <td width="559" align="left" > <select name="middleid" id="middleid" > <option selected="selected">请选择</option> <?php if(is_array($data2)): foreach($data2 as $key=>$result2): ?><option value="<?php echo ($result2["id"]); ?>"><?php echo ($result2["ChineseName"]); ?></option><?php endforeach; endif; ?> </select> <select name="elementaryid" id="elementaryid" > <option selected="selected">请选择</option> <?php if(is_array($data3)): foreach($data3 as $key=>$result3): ?><option value="<?php echo ($result3["id"]); ?>"><?php echo ($result3["ChineseName"]); ?></option><?php endforeach; endif; ?> </select> <select name="smallid" id="smallid" > <option selected="selected">请选择</option> <?php if(is_array($data4)): foreach($data4 as $key=>$result4): ?><option value="<?php echo ($result4["id"]); ?>"><?php echo ($result4["ChineseName"]); ?></option><?php endforeach; endif; ?> </select>*请选择其中一项类别 </td> </tr> <tr> <td align="right">名称</td> <td align="left"><input name="title" type="text" id="title" size="40"></td> </tr> <tr> <td align="right">链接地址</td> <td align="left"><input name="href" type="text" id="href" size="40"></td> </tr> <tr> <td align="center">&nbsp;</td> <td><input type="submit" name="button" id="button" value="提交"> &nbsp;&nbsp;&nbsp;&nbsp; <input type="reset" name="button2" id="button2" value="重置"></td> </tr> </table> </form><?php break;?> <?php case "admin": ?><table width="750" border="1" cellspacing="1" cellpadding="1"> <tr> <td>ID</td> <td>名称</td> <td>链接地址</td> <td>所属类别</td> <td>操作</td> </tr> <?php if(is_array($list)): foreach($list as $key=>$result): ?><tr> <td><?php echo ($result["id"]); ?></td> <td><?php echo ($result["title"]); ?></td> <td><?php echo ($result["href"]); ?></td> <td> <?php if(($result["middleid"] != 0 ) and ($result["elementaryid"] != 0) and ($result["smallid"] != 0 )): ?>中级类别/初级类别/子类别 <?php elseif(($result["middleid"] != 0 ) and ($result["elementaryid"] != 0)): ?> 中级类别/初级类别 <?php elseif(($result["elementaryid"] != 0) and ($result["smallid"] != 0)): ?> 初级类别/子类别 <?php elseif(($result["middleid"] != 0 ) and ($result["smallid"] != 0)): ?> 中级类别/子类别 <?php elseif($result["middleid"] != 0 ): ?> 中级类别 <?php elseif($result["elementaryid"] != 0 ): ?> 初级类别 <?php else: ?> 子类别<?php endif; ?> </td> <td><a href="__URL__/deletedata?type_link=data&handle=admin&link_id=<?php echo ($result["id"]); ?>">删除</a></td> </tr><?php endforeach; endif; ?> <tr> <td colspan="5"><?php echo ($page); ?></td> </tr> </table><?php break;?> <?php default: ?> <table width="750" border="1" cellspacing="1" cellpadding="1"> <tr> <td>ID</td> <td>名称</td> <td>链接地址</td> <td>所属类别</td> <td>操作</td> </tr> <?php if(is_array($list)): foreach($list as $key=>$result): ?><tr> <td><?php echo ($result["id"]); ?></td> <td><?php echo ($result["title"]); ?></td> <td><?php echo ($result["href"]); ?></td> <td> <?php if(($result["middleid"] != 0 ) and ($result["elementaryid"] != 0) and ($result["smallid"] != 0 )): ?>中级类别/初级类别/子类别 <?php elseif(($result["middleid"] != 0 ) and ($result["elementaryid"] != 0)): ?> 中级类别/初级类别 <?php elseif($result["middleid"] != 0 ): ?> 中级类别 <?php else: ?> 子类别<?php endif; ?> </td> <td><a href="__URL__/deletedata?type_link=data&handle=admin&link_id=<?php echo ($result["id"]); ?>">删除</a></td> </tr><?php endforeach; endif; ?> <tr> <td colspan="5"><?php echo ($page); ?></td> </tr> </table><?php endswitch;?>
sunnygirl机器人#7 · 2015/7/27
【 在 zzjin 的大作中提到: 】 : 上面的代码我本地运行没问题啊,编译之后的纯php代码: : [code=php] : <?php if (!defined('THINK_PATH')) exit();?><?php switch($_GET['handle']): ?><?php case "insert": ?><form name="form1" method="post" action="__URL__/common?type_link=data&handle=insert"> : ................... 不知道为啥,我总运行有这个错,我后来改为if else标签了 没错了