Author |
|
JamesBrown
Joined: 03 May 2011 Posts: 1
|
Posted: Tue 03 May '11 0:38 Post subject: Cannot Embed PHP in HTML |
|
|
I have:
Apache 2.2.1
PHP 5.3.6
MySQL 5.5.10
All up and running fine. I can server HTML and PHP pages as advertised. What I can not do is embed PHP in an HTML page. I have tried all the different types of escape codes:
<? ... ?>
<?php ... ?>
<script language="php" > ... <?script>
<% ... %>
None of them have the slightest effect. I think I must have Apache configured wrong - but where? |
|
Back to top |
|
Virsacer
Joined: 16 Jan 2010 Posts: 108 Location: Germany, Darmstadt
|
Posted: Tue 03 May '11 7:42 Post subject: |
|
|
Only php files are parsed by the php interpreter -> rename your .htm(l) to .php |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7373 Location: Germany, Next to Hamburg
|
Posted: Tue 03 May '11 10:06 Post subject: |
|
|
Virsacer wrote: | Only php files are parsed by the php interpreter -> rename your .htm(l) to .php |
not true... you can tell apache with files to parse.
as module
Code: |
AddHandler application/x-httpd-php .php .htm .html
|
with fcgid
Code: |
AddHandler fcgid-script .php .htm .html
FcgidWrapper "c:/php/php-cgi.exe" .php
FcgidWrapper "c:/php/php-cgi.exe" .htm
FcgidWrapper "c:/php/php-cgi.exe" .html
|
For parsing <? and <% you have to edit your php.ini
for <? set short_open_tag = On
for the <% set asp_tags = Off
<?php and <script language="php" > ... <?script> will be parsed by default.
Well much a tag mix doesn't it is well coded.
However, if you still have a question please ask again. |
|
Back to top |
|
Virsacer
Joined: 16 Jan 2010 Posts: 108 Location: Germany, Darmstadt
|
Posted: Thu 05 May '11 11:30 Post subject: |
|
|
James Blond wrote: | you can tell apache with files to parse. |
true... but it is not a good idea.
Depending on the use of the server you might get compatiblity, performance and/or security issues... |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7373 Location: Germany, Next to Hamburg
|
Posted: Thu 05 May '11 14:16 Post subject: |
|
|
Quote: |
Depending on the use of the server you might get compatiblity, performance and/or security issues... |
performance? I tried it a lot with php as module. A file without php tags coast no time. I haven't tried yet with PHP over fcgid.
Security issues? Yes it can be. As I wrote above. Mixing all that file extensions and different kind of PHP tags is a very bad programming attitude. And I don't recommend to do that. it has nothing to do with code cleaness. But if someone comes with a question how to set up a config I tell how to do it, even it is some kinda bad style / behaviour. I not here for parenting |
|
Back to top |
|
Rocker
Joined: 26 Feb 2012 Posts: 16 Location: Brazil
|
Posted: Tue 28 Feb '12 18:04 Post subject: |
|
|
Only an observation,
James Blond, I think you made a mistake...
James Blond wrote: |
for the <% set asp_tags = Off
|
On will enable and Off will disable it...
for the <% set asp_tags = On |
|
Back to top |
|