douyuefu1372 2016-03-06 17:38
浏览 69
已采纳

如何在Yii中使用模板引擎?

I want to write a program with Yii so that users can have their template.

My solution is that every user has a record in a DB to keep a customized template like HTML code and some syntax like Smarty or Twig.

How can I use PHP to get that records and just print it on the screen and my template engine extracts syntax and shows best results? Is that possible or not? How should I do this?

Really you know if you save php codes in database, when you print them into a file, php codes you saved in database don't run. For me the most important thing is that to save template in database whit php commands and then echo them in a file and php code run same usually.

But is is important to use smarty or twig and don't let users add php codes directly.

  • 写回答

2条回答 默认 最新

  • douqian1517 2016-03-07 14:20
    关注

    I found my answer. Just save every thing in database and when load them use eval() function. See documents in php and w3school.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 宇视监控服务器无法登录
  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥50 power BI 从Mysql服务器导入数据,但连接进去后显示表无数据
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签天线)