doushan6692 2009-12-12 16:53
浏览 14
已采纳

函数从其他文件返回字符串

I want to make a really simple template engine for my site, to make it easier to add new pages and edit other ones.

I have a template.php file and a variable of $pageHeader. Then in my functions.php file I have a function called CallHeader() with this code:

function CallHeader()
{
        echo $pageHeader;
}

The problem is this does not echo the contents of $pageHeader to the page. I have included template.php in functions.php using:

include("template.php");

I have also tried setting $pageHeader to be global but nothing works. I'm trying to call this from index.php, which has functions.php included. If I set the CallHeader() function like this:

function CallHeader()
{
        echo "test";
}

It works, and echo's "test" to the page on index.php

Any help as to why I can't echo the contents of $pageHeader? Thanks

  • 写回答

2条回答 默认 最新

  • dongzituo5530 2009-12-12 16:55
    关注

    you tried this and it didn't work ?

    function CallHeader()
    {
        global $pageHeader;
        echo $pageHeader;
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?