dongmeng1868 2011-07-19 15:42
浏览 23

在包含文件内容之前运行功能?

Currently, I'm including my HTML "view" like so:

include $path_to_view;

I would like to be able to run a function on the contents of the view file before I include it, but I'm not sure how to do that and still include the view without using eval:

I basically want to do an "include" type operation on the results of a function. Something like this:

include foo_function(file_get_contents($path_to_view));

How can I accomplish this, or is eval my only option?

Edit

I am using output buffers currently. I am not looking to change the view contents on disk, I just want to get the contents of the view, run a function on those contents, and "include" the contents so they are evaluated.

  • 写回答

2条回答 默认 最新

  • dowm41315 2011-07-19 15:44
    关注

    Look into output buffers. You can put the contents of a file into a var, then parse it as usual.

    Good luck.

    评论

报告相同问题?

悬赏问题

  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?