The question was "The .php extension is a requirement?" The answer is no.
While me and Ash may completely disagree on the php parser, the simple answer is there are many ways around running a non .php extension file in php. mod_rewrite rules in .htaccess files are interpreted for each request and CAN slow down things if your traffic is high. Having said that, mod_rewrite in httpd.conf is faster because it is compiled at server restart and it is native to the server. As a beginner, I completely agree with ash on bad practice rule of thumb. You will simply rewrite the html file later on wishing you had never did the hack to make it function. Richard L. Buskirk -----Original Message----- From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] Sent: Sunday, January 02, 2011 12:16 PM To: ad...@buskirkgraphics.com Cc: 'Adolfo Olivera'; 'Joshua Kehn'; robl...@aapt.net.au; firstname.lastname@example.org Subject: RE: [PHP] Newbie Question On Sun, 2011-01-02 at 11:48 -0500, ad...@buskirkgraphics.com wrote: > Add this to your .htaccess file and HTML files will be handled like PHP > files allowing you put PHP in HTML files. > > AddType application/x-httpd-php .html > > > Richard L. Buskirk > > -----Original Message----- > From: Adolfo Olivera [mailto:olivera.ado...@gmail.com] > Sent: Saturday, January 01, 2011 8:38 PM > To: Joshua Kehn > Cc: robl...@aapt.net.au; email@example.com > Subject: Re: [PHP] Newbie Question > > Sorry, here is the code. The .php extension is a requirement? Can't it b > embedded on a .html file? > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " > http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns=" > http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" > content="text/html; charset=utf-8" /> <title>Untitled Document</title> > </head> <body> <?php $a = "hello"; $hello ="Hello Everyone"; echo $a; echo > $hello; ?> </body> </html> > On Sat, Jan 1, 2011 at 9:55 PM, Joshua Kehn <josh.k...@gmail.com> wrote: > > > On Jan 1, 2011, at 7:50 PM, David Robley wrote: > > > > > > And normally would need to be saved as a .php file so the contents will > > be > > > handled by php. > > > > > > > > > Cheers > > > -- > > > David Robley > > > > > > A fool and his money are my two favourite people. > > > Today is Boomtime, the 2nd day of Chaos in the YOLD 3177. > > > > Save the code as hello.php. Copy it to your root web directory (should be > > the base directory or something called public_html / www when you FTP in) > > and access it from youdomain.com/hello.php > > > > Regards, > > > > -Josh > > ____________________________________ > > Joshua Kehn | josh.k...@gmail.com > > http://joshuakehn.com > > > > > > > -- > Adolfo Olivera > 15-3429-9743 > > It's really best not to think about embedding PHP in an HTML file, as that isn't really how it works and it just encourages bad practices. HTML is embedded inside PHP files, not the other way around. The PHP parser interprets all the PHP code and creates the necessary output, and passes that output along with any HTML to the web server to then deliver to the client (browser). If you embedded PHP inside HTML files, the web server would have to call up the PHP parser every time you broke in and out of PHP tags, which wouldn't do at all! I wouldn't recommend having .html parsed as PHP though, as it will slow down your website/application unnecessarily for any .html files that contain no PHP code, as PHP still has to parse the file for any code, even if there is none. Leave .html files for static pages that you produce with a PHP app for example, or use MOD_REWRITE to reference PHP scripts when certain .html files are requested by the browser, as this can be a whole lot more specific and selective and won't introduce problems later on. Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php