PHP within SSI ?

windows

Guest
I'm trying to get a PHP Script to run within a server side include. Is it at all possible?<br />
<br />
If not, what ways am I going to have to do it? the include is .html and I am including the page on a .shtml<br />
<br />
PHP is on the .html page.<!--content--><!--#include virtual="/somedir/file.php" --><br />
<br />
I pretty sure the above should work fine as long as the page is parsed by PHP. Make sure the PHP file has a .php or similar extention. Your page with the SSI on it should have a .shtml ext. or whatever your server is configured to parse as pages with SSI.<br />
I hope this helps. :)<br />
Peace,<br />
Ed<!--content-->PHP is on the .html page.<br />
<br />
php wil never be parsed if it is in a html page.<!--content-->Originally posted by scoutt <br />
PHP is on the .html page.<br />
<br />
php wil never be parsed if it is in a html page. <br />
<br />
I am afraid you can scoutt ;)<br />
<br />
to include PHP into html do the following:<br />
<br />
<?php<br />
insert your php here<br />
?><br />
<br />
You should have no problems with that.<!--content-->no you can't. php will not be parsed if the page doesn't end in php. try it and the php part will be outputted to the screen as text. it is not as easy as you think.<br />
<br />
now with that said, yes you could do that but every html document will have to be parsed by the php engine and that will run the resources of the server throught the roof. it is not recommended to do that because it wouldn't matter if ther ewas php in the html document it still will be parsed through the php engine.<!--content-->I would have to beg to differ... the way demonstrated is perfectly legit. It is also really aimed at small php snips rather than 100% php pages. You can do exactley the same thing with ASP as well.<br />
<br />
What I don't understand is how this can increase the load on the server?<br />
<br />
Two options:<br />
1, you write the whole thing in php.<br />
2, you write it as a snippet embedded in html.<br />
<br />
both of the above will create the same workload for a server.<!--content-->have you tried it???<br />
<br />
because it is like this.<br />
<br />
<br />
file.html<br />
<html><br />
<body><br />
<?php<br />
phpinfo();<br />
?><br />
</body><br />
</html><br />
<br />
that file right there will not run php. becasue it being a .html why you ask, the php engine will never see it to parse it as it has a .html extension.<br />
<br />
Two options:<br />
1, you write the whole thing in php.<br />
then it works becasue php sees it and it can parse it.<br />
2, you write it as a snippet embedded in html<br />
then it won't work, because php can't parse html<br />
<br />
<br />
What I don't understand is how this can increase the load on the server?<br />
because when you have a .html file it doesn't get parsed as php. when you have a php file it gets parsed as php. if you set th eserver up to parse everyhting under the sun as php, well then that will make teh resources go up as not every file will have php in it. that is not real world.<br />
<br />
run it and see. that is if you server is not setup to parse everyhting as php.<br />
<br />
go ahead and try it and let me know.....<!--content-->Ok we will have to agree to disagree. As usual ;)<br />
<br />
PHP is a HTML embedded scripting language. I don't know why you are having problems with the code you have shown. I can only assume your server doesn't have PHP permissions or it isn't written correctly.<br />
<br />
Do a little search with the phrase "embed php in html" and you will find a whole host of results showing you how and why this is legit.<br />
<br />
So we agree to disagree then?<!--content-->Can I just clear one thing up first tho...<br />
I presume that waats has changed the extension of his page to *.php even though it is written as normal html.<!--content-->Originally posted by entimp <br />
Ok we will have to agree to disagree. As usual ;)<br />
<br />
PHP is a HTML embedded scripting language. I don't know why you are having problems with the code you have shown. I can only assume your server doesn't have PHP permissions or it isn't written correctly. <br />
what are you on???? php is not or has nothing to do with html. php is a serverside language.<br />
<br />
show me a page that says this?<br />
<br />
PHP will not run in html<br />
and no, we are not agreeing to disagree.<!--content-->Originally posted by scoutt <br />
what are you on???? php is not or has nothing to do with html. php is a serverside language.<br />
<br />
show me a page that says this?<br />
<br />
PHP will not run in html<br />
and no, we are not agreeing to disagree. <br />
We don't agree... so I agree to disagree, you don't have to. I maintain that if you write a standard html page, embed the PHP (I stress save the extension as .php) it will work fine and is legit.<br />
<br />
PHP whether you like it or not is a HTML embedded scripting language.<br />
PHP is an HTML-embedded scripting language (a qutoe form the horses mouth)<br />
<!-- m --><a class="postlink" href="http://uk.php.net/manual/en/faq.general.php">http://uk.php.net/manual/en/faq.general.php</a><!-- m --><br />
When PHP parses a file, it simply passes the text of the file through until it encounters one of the special tags which tell it to start interpreting the text as PHP code. The parser then executes all the code it finds, up until it runs into a PHP closing tag, which tells the parser to just start passing the text through again. This is the mechanism which allows you to embed PHP code inside HTML: everything outside the PHP tags is left utterly alone, while everything inside is parsed as code. <br />
<!-- m --><a class="postlink" href="http://uk.php.net/manual/en/language.basic-syntax.php">http://uk.php.net/manual/en/language.basic-syntax.php</a><!-- m --><!--content-->Originally posted by entimp <br />
(I stress save the extension as .php) it will work fine and is legit. <br />
you never said that. you talked about the extension as html.<!--content-->Originally posted by entimp <br />
Can I just clear one thing up first tho...<br />
I presume that waats has changed the extension of his page to *.php even though it is written as normal html.<!--content-->well yes, but after you argued tha tit will work. read my first post<br />
<br />
<br />
Originally posted by scoutt <br />
PHP is on the .html page.<br />
<br />
php wil never be parsed if it is in a html page. <br />
and you said it will work like that.<br />
<br />
:P<!--content-->Hi everybody.<br />
Nice healthy discussion going on here :D :D<br />
<br />
Can I add my two-cents (two-pence) worth?<br />
<br />
Q) Can a page with a .html or .htm extension execute PHP?<br />
A) Typically no! Usually servers that can execute PHP require the php file to have a .php extension. The server can be configured to parse PHP code in a .html file, however, this is generally considered bad-practice and a waste of system resources.<br />
<br />
Q) Can PHP be embedded inline within HMTL<br />
A) Yes, absolutely.<br />
<br />
Q) Will Scoutt and Entimp remain friends?<br />
A) Yes, I'm sure they will. Nothing wrong with a bit of healthy debate every now and then :)<br />
<br />
Q) Is Torrent a nosey b*****d for sticking his oar in?<br />
A) Yup.<!--content-->
 
Back
Top