![]() |
Newby, first gotchme!!
here is my code:
Code:
<html>Quote:
Why am I getting that Quote:
David. |
Use <?php ..... ?> , <?php echo $var; ?>, <?php $var="string"; ?> instead of the short open tags ( <? ....?>, <? echo $var; ?>, <?="string" ?>. Short open tags look more convenient but they only cause more problems.
Btw, short open tags will be done away with in PHP 6. |
Well that didn't work. In fact, i originally had the long tags, but changed it to the short to see if it made any difference.
Any other ideas? From what I can see, the code looks ok. Oh, this document is named as test.html I take it it should be with a html suffix and not php, right? I'm on win 7. I did write a small script with just the php tags and called it test.php and ran that one and that worked ok. |
Quote:
|
Name it test.php not .html
Also call it via your webserver NOT just by double clicking it. EG: http://localhost/test.php |
Quote:
I read somewhere that it's like this Code:
# Use PHP5 by defaultWhich file do I have to put these lines in? Dave. |
Quote:
Does anyone know how to do this? I'm pretty sure it has to be in the .htaccess file but that file doesn't seem to let the server work when I manipulate that file. I'm not sure if it's because I'm using XAMPP and I'm supposed to put it in some other proxy file. David |
You can't, or more accurately you do not want to (I'm sure it could be done, but it would be very unwise). File protocol is a filesystem access protocol. If you chain it to webservices for preprocessing, than you will not be able to open files properly. IE: I can open any file on my machine by typing in file://path/to/file.txt, so the last thing I want is to have it intercepted by webservers for preprocessing.
Always access it through the http protocol or on the command line via php.exe execution. |
Quote:
AddType application/x-httpd-php .html Also as Redcoder says, drop the short tags. They were supposed to be a useful thing once but they're a pita as not all servers have them enabled - makes life hell when moving from one server to another. Additionally it also wreaks havoc with any .xml files you also have if .xml is configured to be run by php using the AddType in your .htaccess file. |
I fixed it. I found this off another forum in a google search.
I had to change this file in xampp \xampp\apache\conf\extra\httpd-xampp.conf from: <FilesMatch "\.php$"> to: <FilesMatch "\.(php|html)$"> So that's fixed. My second question would be, are there any dangers to doing this? Or do we generally want to make web applications that will use the parsing of php in html files. David |
That fix means that your apache / php will now check every file across every directory. That'll grind it down a bit more and imagine what will happen on a live server with thousands of visitors..
As for the .html thing, yes there is a reason why we don't recommend it. .html is used for static pages that don't change. .php is used for dynamic pages. If you use .html for dynamic then the webserver has to check every .html page for dynamic content which given enough users and connections will grind it down. Thats why we have the .php extension so that you can choose and switch between resource intensive and non resource intensive. It's also why it's recommended to use the .htaccess file instead of the main config file for some things because you casn specify different options for different folders. You've just with overkill lol. If you really want to hide the use of php then just use folder names and index.php file names to mask it. EG: /account/ /edit/ /update/ In each of those folders you have index.php but you never call or link to the php file, just the actual folder. The webserver will serve the index file by default. |
Thanks Tango.
I will change it back then since it's not recommended. |
| All times are GMT +1. The time now is 07:53 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.