Do pages need to be named .php to execute PHP code?

  • CazpianXI
  • Proficient
  • Proficient
  • User avatar
  • Joined: Dec 22, 2003
  • Posts: 285
  • Status: Offline

Post April 13th, 2004, 12:26 pm

I'm develop some free PHP code, and I'm just curious about something with PHP...

Do pages have to be named .php, .php3, or .phtml in order to execute PHP code? Can .html pages run PHP code as long as the server has PHP installed?

The reason I'm asking this question is this: I'd like to be able to tell my users to use my software they just stick [blur]<?php include "whatever.inc"; ?>[/blur] into any page on their site. Or, do I need to tell them to rename their page(s) to .php first?

Thanks.
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post April 13th, 2004, 12:26 pm

  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23403
  • Loc: Woodbridge VA
  • Status: Offline

Post April 13th, 2004, 12:44 pm

I believe the answer to that is yes, so that the php engine knows to examine the document and execute the php code blocks and return the document as HTML.
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • Managedlinks
  • Proficient
  • Proficient
  • No Avatar
  • Joined: Mar 31, 2004
  • Posts: 294
  • Status: Offline

Post April 13th, 2004, 5:18 pm

The answer actually is no. but the level of difficulty depends on the servers admin

you need to modify the .htaccess file if it is available to the user.

an example is here...
http://www.managedlinks.com/htaccess.html
This page you will notice is html and yet it is actually an executed php page

P.S. no disrespect intended Atno, I have only just learnt this trick myself
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23403
  • Loc: Woodbridge VA
  • Status: Offline

Post April 13th, 2004, 5:30 pm

No disrespect taken -- excellent find! Thanks. Bookmarked and "away we go..."~!
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • Managedlinks
  • Proficient
  • Proficient
  • No Avatar
  • Joined: Mar 31, 2004
  • Posts: 294
  • Status: Offline

Post April 13th, 2004, 5:50 pm

The only downside is it will parse all files as php. and therefore slow the server down a tad.

it should not be much of a concern though as I think apache is pretty efficient when it comes to parsing a file.

I wonder if you can selectivally choose which file to parse. perhaps a little experimentation is in order.

Post Information

  • Total Posts in this topic: 5 posts
  • Users browsing this forum: Kurthead+1 and 129 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.