At 2:04 PM +0000 1/10/09, Nathan Rixham wrote:
tedd wrote:
At 5:39 PM +0000 1/9/09, Nathan Rixham wrote:
if it has the file extension .php then it will be passed through php and compiled; otherwise the php source code you insert will just show up in the html source.

Gary:

That is true, but with the following code in a .htaccess file you can force the interpreter to consider other files with other suffixes. For example:

# handler for phpsuexec..
<FilesMatch "\.(htm|html|css|tpl)$">
 SetHandler application/x-httpd-php
</FilesMatch>

This allows me to use php in css files and such.

Cheers,

tedd


PS: Nathan -- I know you know this, but this post was for the benefit of the OP.

lol and I knew *somebody* would say that :p
"np; you may get some comments about being able to configure you're server so that php parses files with different extensions (such as .html); but this would require some customisation of the web server config files and probably best avoided for now."

Gary:

I agree with Nathan here.

If you have problems with using the php suffix or don't want to change from html, then what I presented is an option, but it's debatable as being good practice.

I think that using "php" suffixes tells you (as the developer) that some portion of the file has php code in it somewhere and that's usually good to know, thus good practice.

As you learn and grow you'll see the differences between and advantages for the separation of data, presentation, behavior, and function -- the four horseman of web development (much more than a single language). I could write a whole treaties on these differences and how different languages treat these different constructs. As they say in Perl "There's always more than one way to do something."

In any event, it's probably good to use the php suffix if that doesn't brother you much. But it's also good to know that you have the option.

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to