logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Coding & Scripting Corner View previous topic :: View next topic
Reply to topic   Topic: Cannot Embed PHP in HTML
Author
JamesBrown



Joined: 03 May 2011
Posts: 1

PostPosted: Tue 03 May '11 0:38    Post subject: Cannot Embed PHP in HTML Reply with quote

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

PostPosted: Tue 03 May '11 7:42    Post subject: Reply with quote

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: 7371
Location: Germany, Next to Hamburg

PostPosted: Tue 03 May '11 10:06    Post subject: Reply with quote

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

PostPosted: Thu 05 May '11 11:30    Post subject: Reply with quote

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: 7371
Location: Germany, Next to Hamburg

PostPosted: Thu 05 May '11 14:16    Post subject: Reply with quote

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 Wink
Back to top
Rocker



Joined: 26 Feb 2012
Posts: 16
Location: Brazil

PostPosted: Tue 28 Feb '12 18:04    Post subject: Reply with quote

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


Reply to topic   Topic: Cannot Embed PHP in HTML View previous topic :: View next topic
Post new topic   Forum Index -> Coding & Scripting Corner