koalajiang Posted October 2, 2013 Share Posted October 2, 2013 Hi: I was reading chapter 12, and found script 12.7 line 19 embed with php code? i am wondering how a html file can execute this php code? Should you change the header.html to header.php? Link to comment Share on other sites More sharing options...
Larry Posted October 2, 2013 Share Posted October 2, 2013 Good question! The header.html is being included by PHP, so it's as if the header.html code is part of the original PHP script. It could have literally any extension and still work. Link to comment Share on other sites More sharing options...
koalajiang Posted October 2, 2013 Author Share Posted October 2, 2013 Hi Larry: You mentioned that The header.html is being included by PHP. Do you mean in the index.php file -- <?php # index.php $page_title = 'xxxxx'; include ('./includes/header.html'); ?> so that header.html code is part of the original php script?? If so why when i type php code in header.html file with netbeans, there is no code hint, and also the php code color is light blue? Link to comment Share on other sites More sharing options...
Antonio Conte Posted October 2, 2013 Share Posted October 2, 2013 Also remember that PHP is an interpreted language. That means that PHP code is executed by a interpreter, not from a compiled source. The file extension .php has no special functionality. The interpreter might also run .html, .txt or .randomExtension as PHP if you can just tell PHP and Apache to treat it that way. This article might clear some things up: http://php.about.com/od/advancedphp/p/html_php.htm Link to comment Share on other sites More sharing options...
Larry Posted October 3, 2013 Share Posted October 3, 2013 Netbeans probably only uses the file's extension to know how to behave. It doesn't understand the greater context. If that's a problem, use .php for the header file extension. Link to comment Share on other sites More sharing options...
Recommended Posts