phporcaffeine Posted November 30, 2006 Share Posted November 30, 2006 Okay, I know this is a simple problem with a solution but I don't know what it is.I have an html file, in the file I am trying to execute php tags like;<?php <i>the php tags</i> ?>When executed in the browser the html is rendered but the php tags are not. If I do a 'view source' on the page, the literal text of the php tag is there but it doesn't execute?-TIA Quote Link to comment https://forums.phpfreaks.com/topic/29012-silly-problem/ Share on other sites More sharing options...
craygo Posted November 30, 2006 Share Posted November 30, 2006 Sounds like a server problem. What web server you using apache, IIS??Are you echoing or printing anything out between the tags??Ray Quote Link to comment https://forums.phpfreaks.com/topic/29012-silly-problem/#findComment-132917 Share on other sites More sharing options...
piznac Posted November 30, 2006 Share Posted November 30, 2006 Question,. this may sound silly. But is this page a .html or .php? Quote Link to comment https://forums.phpfreaks.com/topic/29012-silly-problem/#findComment-132918 Share on other sites More sharing options...
.josh Posted November 30, 2006 Share Posted November 30, 2006 unless you have set your server to parse the file type (.php, .html, .blah) as php, it won't parse the php. Quote Link to comment https://forums.phpfreaks.com/topic/29012-silly-problem/#findComment-132919 Share on other sites More sharing options...
phporcaffeine Posted November 30, 2006 Author Share Posted November 30, 2006 if the page is a ' .php ' it will execute php just fine - a '.html' page will execute html fine. A .php page wil render html fine.The issue is being able to include php tags inside of a .html file via <?php ?> I am using apache 2.2.3[code]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><title>Planitlanit</title></head><body>test<?php require('navibar.html'); ?>testt</body></html>[/code]When I execute the above .html file, everything renders BUT the '<?php ?>' part. I can see the literal "<?php require('navibar.html'); ?>" when I view source and that is it. Quote Link to comment https://forums.phpfreaks.com/topic/29012-silly-problem/#findComment-132923 Share on other sites More sharing options...
craygo Posted November 30, 2006 Share Posted November 30, 2006 you can set your server to parse .html files with php instead of just the browser.Ray Quote Link to comment https://forums.phpfreaks.com/topic/29012-silly-problem/#findComment-132925 Share on other sites More sharing options...
phporcaffeine Posted November 30, 2006 Author Share Posted November 30, 2006 How do you mean? Quote Link to comment https://forums.phpfreaks.com/topic/29012-silly-problem/#findComment-132926 Share on other sites More sharing options...
piznac Posted November 30, 2006 Share Posted November 30, 2006 Wow I didnt know that,.. I thought it had to be .php to parse the php Quote Link to comment https://forums.phpfreaks.com/topic/29012-silly-problem/#findComment-132929 Share on other sites More sharing options...
phporcaffeine Posted November 30, 2006 Author Share Posted November 30, 2006 [quote author=craygo link=topic=116871.msg476477#msg476477 date=1164918397]you can set your server to parse .html files with php instead of just the browser.Ray[/quote]How would I do this? Quote Link to comment https://forums.phpfreaks.com/topic/29012-silly-problem/#findComment-132931 Share on other sites More sharing options...
craygo Posted November 30, 2006 Share Posted November 30, 2006 Read thishttp://textsnippets.com/posts/show/310ray Quote Link to comment https://forums.phpfreaks.com/topic/29012-silly-problem/#findComment-132932 Share on other sites More sharing options...
phporcaffeine Posted November 30, 2006 Author Share Posted November 30, 2006 [quote author=craygo link=topic=116871.msg476484#msg476484 date=1164918880]Read thishttp://textsnippets.com/posts/show/310ray[/quote]for those not in the mood to surf ---AddHandler application/x-httpd-php .html Quote Link to comment https://forums.phpfreaks.com/topic/29012-silly-problem/#findComment-132935 Share on other sites More sharing options...
piznac Posted November 30, 2006 Share Posted November 30, 2006 wow now thats pretty cool stuff Quote Link to comment https://forums.phpfreaks.com/topic/29012-silly-problem/#findComment-132940 Share on other sites More sharing options...
craygo Posted November 30, 2006 Share Posted November 30, 2006 phpORcaffine that's cool but where do they put it if they didn't read the snippet?? :)ray Quote Link to comment https://forums.phpfreaks.com/topic/29012-silly-problem/#findComment-132974 Share on other sites More sharing options...
Psycho Posted November 30, 2006 Share Posted November 30, 2006 It seems there is some confusion of how server-side scripting works. Just because a file has php code in it means nothing. The server must first be configured to process PHP code - then the server must be told what file to process as PHP. When a user requests a page from the server, the server will check the list of file types that it is supposed to process. If the file is not in the list, then it simply delivers the file as-is to the browser. If the file is in the list of files to be processed, it sends it to the appropriate interpreter (PHP, ASP, etc.) and acts on any code within the file. The "output" of this processing is then delivered to the browser - not the file.In fact, you can set your server to process files with the .asp extension as PHP. That will really confuse people! Quote Link to comment https://forums.phpfreaks.com/topic/29012-silly-problem/#findComment-132983 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.