doutuan6158 2011-04-23 13:59
浏览 65
已采纳

Joomla:在文章中写出真正的PHP

I am trying to find a way to write pure PHP in my articles with Joomla (currently using 1.5). The closest I got so far was to use a plugin called Sourcerer (see link)

The issue is that the PHP code is actually being rendered as HTML. When I write the below code via the Sourcerer editor:

<?php echo "Hello world"; ?> 

This is what is being written to the article:

<span>&lt;</span>?php echo "Hello world"; ?<span>&gt;</span>

I am afraid that at some point this is going to break my PHP if I come up with more complex code. Also this makes the code hardly readable. Finally the issue with Sourcerer is that you can only insert new code, you can't edit what you previously added.

[Q] Does anybody know a way to write pure PHP into articles?

I would like to insist on the fact that it has to be within articles. I already found a way to do it in modules or components, for instance with Jumi (see link)

  • 写回答

4条回答 默认 最新

  • dongliechuich10319 2011-04-24 01:38
    关注

    I have used Sourcerer a couple of times and it does allow one to insert PHP snippets into articles without issues. If your php is being rendered as html, it sounds like the php isn't getting parsed as php - first thing is to make sure that the sourcerer plugin is indeed enabled so it can allow your php scripts to get parsed. (check plugin enabled status here: extensions->plugin manager->sourcerer).

    Also, use the sourcerer ("Insert Code") button at the bottom of your WYSIWYG editor when adding your PHP scripts - it keeps the formatting/syntax highlighting and ensures that it is escaped properly with the {source} {/source} tags.

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

报告相同问题?

悬赏问题

  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码