html内部的php代码正在被注释掉 [英] php code inside html is being commented out

查看:110
本文介绍了html内部的php代码正在被注释掉的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的php代码是在 wordpress 页面中的html代码中调用的。但它正在被浏览器注释掉。
代码:

 <?php if(function_exists(gCF))gCF(); ?> 

里面的内容被读作如下(当我在firebug或chrome中看到时)

 <! - ?php if(function_exists(gCF))gCF(); ? - > 

我搜索了网络并发现了类似的问题,但遗憾的是没有适当的解决方案,也没有任何人都提到了这是为什么发生。是因为doctype吗?



问题1
问题2
问题3
问题4



在此先感谢。

解决方案

这听起来像代码是在一个文件它没有 .php 扩展名,因此代码被评估为 HTML



如果您想在wordpress中使用 php ,请确保它位于模板文件中(既可以是现有的,也可以是已经制作的)。

My php code is called from the html code in a wordpress page. However It is being commented out by the browser. The code:

<?php if (function_exists (gCF)) gCF(); ?>

inside a div is being read as following (when I see in firebug or chrome)

<!--?php if (function_exists (gCF)) gCF(); ?-->

I searched the net and found following similar questions, but sadly there is no apt solution, and nor has anyone mentioned why this is happening. Is it because of doctype???

Question 1 Question 2 Question 3 Question 4

Thanks in advance.

解决方案

It sounds to me like the code is inside a file that does not have a .php extension and therefore the code is being evaluated as HTML.

If you want to use php in wordpress, make sure it's in a template file (either an existing one or one that you've made).

这篇关于html内部的php代码正在被注释掉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆