onlyican Posted August 12, 2006 Share Posted August 12, 2006 HeyI know you can have php code in the following tags<% %> (I know this is known as ASP, but it works in PHP as well)<? ?> (Common used)<?= ?> (forgotten)<?php ?> (Mainly used with classes)AND<script language="php"> </script>My questionIf a website is hosting with a PHP serverCan i have<script language="php"> </script> in HTM pages, and everything works Quote Link to comment https://forums.phpfreaks.com/topic/17330-php-in-htm-pages/ Share on other sites More sharing options...
zq29 Posted August 12, 2006 Share Posted August 12, 2006 As far as I'm aware, you can do that if you configure your web server to process .htm files with the PHP interpreter.[quote author=onlyican link=topic=103976.msg414510#msg414510 date=1155386671]<% %> (I know this is known as ASP, but it works in PHP as well)<? ?> (Common used)<?= ?> (forgotten)[/quote]For the above three, I believe they need to be specifically enabled in your php.ini to be usable, not all servers have short tags enabled so they shouldn't be used commonly as you have annotated. Quote Link to comment https://forums.phpfreaks.com/topic/17330-php-in-htm-pages/#findComment-73664 Share on other sites More sharing options...
AndyB Posted August 12, 2006 Share Posted August 12, 2006 The downside to configuring your server to parse .htm files is that it will parse every .htm file whether it needs to or not. That adds server load which you may not want.A simple alternative which I've used successfully is detailed at http://www.javascriptkit.com/javatutors/externalphp.shtml Quote Link to comment https://forums.phpfreaks.com/topic/17330-php-in-htm-pages/#findComment-73665 Share on other sites More sharing options...
onlyican Posted August 12, 2006 Author Share Posted August 12, 2006 most servers have <? ?>and <?php ?>configured as standardwhilst<% %> and <?= ?> are not normallyif you are using a server with mixed ASP / php then <% %> will not as it is Standard ASP tags Quote Link to comment https://forums.phpfreaks.com/topic/17330-php-in-htm-pages/#findComment-73679 Share on other sites More sharing options...
wildteen88 Posted August 12, 2006 Share Posted August 12, 2006 [quote author=onlyican link=topic=103976.msg414529#msg414529 date=1155391404]most servers have <? ?>and <?php ?>configured as standardwhilst<% %> and <?= ?> are not normallyif you are using a server with mixed ASP / php then <% %> will not as it is Standard ASP tags[/quote]Actually most servers have <?php and ?> and,<script langauge="php"></script>as standard.If you want to use <? ?> rather than <?php ?> you'll have to turn on the short_open_tag directive. This directive also allows you to use <?= ?> as shortcut to using <?php echo blah ?>If you want to use <% %> as PHP tags you'll need to turn on the asp_tags direcitve.Also note the following tags <? ?>, <% %> and <?= ?> will be removed as of PHP6. Quote Link to comment https://forums.phpfreaks.com/topic/17330-php-in-htm-pages/#findComment-73700 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.