(求助)Smarty include PHP文件出现的问题 补充一下。如果在index.php中,直接用PHP脚本include("votes.php");是可以正常运行的。就是Smarty后无法正常运行,奇怪。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 votes.php是没有问题,但是显示和投票是写在一个页里的,很杂乱,大概是长成这样。//定义动作页$action = $_GET['action'];switch($action){ case 'show': showVotes(); break; //处理投票和显示投票结果页面 default: votes(); //显示投票页面}//显示投票页面function votes(){ ……代码……}//处理投票和显示投票结果页面function showVotes(){ ……代码……}<!--还有段JS代码:用来控制打开新窗口大小的--><script language="javascript">var wWidth=650; var wHeight=500; function setAction(){ form.action="?action=show"; form.target="a1"; window.open("about:blank","a1","width='+wWidth+',height='+wHeight+',left="+(window.screen.width-wWidth)/3+",top="+(window.screen.height-wHeight)/3+",status=no,location=no,toolbar=no, directories=no,menubar=no"); form.submit();}</script> try:======================={literal}<script language="javascript">.........</script>{/literal} 谢谢你的回答,但是我试过了,不管用。votes.php没有使用模板,只是要include我看过了template_c下编译过的index.php文件代码,它把{include_php file="votes.php"}生成了如下代码:<?phprequire_once(SMARTY_CORE_DIR . 'core.smarty_include_php.php');smarty_core_smarty_include_php(array('smarty_file' => "votes.php", 'smarty_assign' => '', 'smarty_once' => false, 'smarty_include_vars' => array()), $this);?>我在编译过的文件中把以上代码改成了:include("votes.php");votes.php无法正常工作。只有直接再未编译的index.php中include("votes.php"); votes.php才能正常工作。搞不懂index.php和index.htm之间的微妙关系。唉……头大。 include不好用啊。不是符号问题,就是不能编译。。换个方式把 要用相对路径就要用 $trusted_dir 谢谢各位回答,我试过了。也不是路径的问题。xiongbing529(代码人生)说的对,是编译问题了。问题就出在被编译的文件中,可是有什么好的解决方式呢?唉…… smarty怎么被楼主搞得这么复杂, 谢谢 zhangli(我来也!)虽然没有解答问题的关键所在,但是给出了十分好的解决方案。等结题了,也给你一半分吧。 你那个{include_php file="votes.php"}改成{php} include("votes.php");{/php}这样试试 关于apache调优的一些问题 怎么给GIF格式的图片上的文字加背景颜色啊 PHP高级技术交流群:45067352 什么意思? 为什么数值可以插入,而变量不能?? 烦烦烦烦烦烦烦烦烦烦烦烦烦烦烦烦烦烦烦烦烦烦 关于PHP的SESSION的问题 大家进下面这个网址,帮看看怎样改这些错误,谢谢了 急!如何用文本框提交表单? copy函数的问题 100分请高手翻译小段PHP代码成ASP的!!着急 关于header的问题
$action = $_GET['action'];
switch($action)
{
case 'show': showVotes(); break; //处理投票和显示投票结果页面
default: votes(); //显示投票页面
}//显示投票页面
function votes()
{
……代码……
}//处理投票和显示投票结果页面
function showVotes()
{
……代码……
}<!--还有段JS代码:用来控制打开新窗口大小的-->
<script language="javascript">
var wWidth=650;
var wHeight=500;
function setAction()
{
form.action="?action=show";
form.target="a1";
window.open("about:blank","a1","width='+wWidth+',height='+wHeight+',left="+(window.screen.width-wWidth)/3+",top="+(window.screen.height-wHeight)/3+",status=no,location=no,toolbar=no, directories=no,menubar=no");
form.submit();
}
</script>
=======================
{literal}
<script language="javascript">
...
..
.
.
.
.
</script>
{/literal}
<?php
require_once(SMARTY_CORE_DIR . 'core.smarty_include_php.php');
smarty_core_smarty_include_php(array('smarty_file' => "votes.php", 'smarty_assign' => '', 'smarty_once' => false, 'smarty_include_vars' => array()), $this);
?>我在编译过的文件中把以上代码改成了:include("votes.php");votes.php无法正常工作。只有直接再未编译的index.php中include("votes.php"); votes.php才能正常工作。搞不懂index.php和index.htm之间的微妙关系。唉……头大。
{include_php file="votes.php"}
改成
{php}
include("votes.php");
{/php}
这样试试