php code inside html is being commented out

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)

Read More
<!--?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.

Related posts

Leave a Reply

3 comments

  1. 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).

  2. It’s possible that the file is not being parsed by PHP. Make sure the file extension is PHP or your server is setup to parse that filetype using PHP.