I'd like to include a .shtml file in a .php page. I know it is possible, as i have done it before (though i've forgotten the code). Please can someone help?
Asked
Active
Viewed 1,329 times
0
-
4Why not just use a php include or file_get_contents? shtml isn't used much these days. – Rich Bradshaw Nov 27 '12 at 21:24
-
my site is written entirely in shtml. i am writing a php application and must be able to include a shtml file – Aqr Aqr Nov 27 '12 at 21:27
-
What do you want to archive exactly? – Green Black Nov 27 '12 at 21:28
-
basically i have header.shtml file which i need to include in home.php – Aqr Aqr Nov 27 '12 at 21:30
-
2You might be looking for [`virtual`](http://php.net/virtual). – hakre Nov 27 '12 at 21:33
-
how would i go about doing it? i am using this code it doesn't seem to be working – Aqr Aqr Nov 27 '12 at 21:34
2 Answers
0
Did you try :
echo file_get_contents('/includes/header.shtml');
// or
echo file_get_contents('includes/header.shtml');
It might work.
But I would just start converting all the templates to any of available php templating engines.

E_p
- 3,136
- 16
- 28
-
-
1Can us tell what is your folder layout. As `'/include/header.shtml'` does not seam right – E_p Nov 27 '12 at 22:00
-
/includes/header.shtml is correct since the folder "includes" is in the top-level of the domain and the shtml file is within it. the test.php file is in a folder also in the top-level of the domain. – Aqr Aqr Nov 27 '12 at 22:03
-
Based on your last comment I was right. You need `echo file_get_contents('includes/header.shtml');` or even just `require 'includes/header.shtml';` would work. Just try it. – E_p Nov 27 '12 at 22:12
-
-
I've found out it only works when specifying an absolute url, e.g. `echo file_get_contents('http://sitename.com/file.shtml');`. Otherwise, the SSI will not parse and remain HTML comments. – mnsth Mar 03 '15 at 13:19