0

Sorry guys this is probably pretty simple, but i've been up way too late now. I have a basic html page and when i try to put any php in the body it reads it as a comment.

<html>
<body>
.... ....
</p>
</div>
<div id='result' class='ui-widget' style='width:70%;margin:0 auto'>
</div>
</div>
<?php 
include(WEB_ROOT.'/template/footer.php'); 
?>

</body>
</html>

Is there anything wrong?

5
  • 5
    Obvious question but are you saving the file as *.php? Commented Aug 17, 2011 at 10:58
  • What do you see if you echo WEB_ROOT? Commented Aug 17, 2011 at 10:58
  • I save the footer as footer.php and by using echo WEB_ROOT the same can be seen Commented Aug 17, 2011 at 11:04
  • do you get an error if you replace the include with require? Commented Aug 17, 2011 at 11:14
  • I find out the root cause, I use a template() to construct the html file and this function use echo file_content as return. Apparently wrong. Commented Aug 17, 2011 at 11:32

2 Answers 2

1

You must use a server like Apache which interprets the page. What's more, it should have a .php extension.

Sign up to request clarification or add additional context in comments.

3 Comments

Yes, I use Apache server and view the html from Chrome browser, if I replace the "include " with "echo xxx", it works.
And you can see your code in the HTML code of the page as a comment ?
I find out the root cause, I use a template() to construct the html file and this function use echo file_content as return. Apparently wrong.
0

Problem of extension ! .PHP not .HTML ! The opposite is correct ! including html in php page

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.