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

  • CazpianXI
  • Proficient
  • Proficient
  • User avatar
  • Posts: 285

Post 3+ Months Ago

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
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

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.
  • Managedlinks
  • Proficient
  • Proficient
  • Managedlinks
  • Posts: 294

Post 3+ Months Ago

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
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

No disrespect taken -- excellent find! Thanks. Bookmarked and "away we go..."~!
  • Managedlinks
  • Proficient
  • Proficient
  • Managedlinks
  • Posts: 294

Post 3+ Months Ago

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: No registered users and 45 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
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.