Page 1 of 1
How do I include a PHP function in an .shtml file?
Posted: Wed May 14, 2003 6:46 pm
by Stricklin
I'd like to include a
PHP4 function in my
index.shtml page, but everytime I place the function within the <HEAD></HEAD> section as I'm told, the function appears as text at the top of my page.
I'm told that I
have to use the .shtml extension if I'm to have the server-side include in my index page execute, and I'm told that any PHP code must be in a page having the .php4 extension. But what if I want both?
Some in the
Movable Type Support Forum have suggested that "There's some sort of declaration (similar to a script declaration for javascript)."
Does such a declaration exist? If not, can anyone advise further?

Posted: Thu May 15, 2003 1:15 am
by volka
there's a <!--#exec cmd=...>
command for SSI. If your provider allows that you might call php as cgi and have a script executed.
the php-module for apache2 is implemented as filter. This openes some new features (or makes them available easier). You can have multiple
handlers for one document, passing the source/output-stream through each filter.
Let's say PHP is the first
handler, not only get's your source parsed and executed as php-script before SSI takes place, the script might also add new
<!-- #SSI command --> lines to the output stream. SSI will parse them. Groovy, isn't it

Posted: Thu May 15, 2003 3:38 am
by Gleeb
If you're using SHTML purely to include other files, you might want to look into
include()
Posted: Thu May 15, 2003 3:43 am
by []InTeR[]
Gleeb wrote:If you're using SHTML purely to include other files, you might want to look into
include()
PHP cannot be used in the SHTML file.
You have to include a php file with Server Side Includes.
Posted: Thu May 15, 2003 4:02 am
by Gleeb
I was indicating that if you're using SHTML just for incuding other files, you might want to replace it all with
include(), or, come to think of it,
readfile()
This allows you to use PHP and still get the same effects as SHTML
Edit: BBCode markup fix ... additional edit: if you can read this without a loupe your monitor is too large.... sorry, couldn't resist, volka
Include() works great
Posted: Sat May 17, 2003 9:42 am
by Stricklin
Just a note to you guys to tell you that Include() worked perfectly and to thank everyone who weighed in to help. If you want to see the results, visit my page at
http://www.charlesstricklin.com/