jimfog Posted December 1, 2013 Share Posted December 1, 2013 Here is a question I always had and now is the opportunity to ask. If someone wants to write PHP code, what is it better, using a php file extension or an html file extension and just put the php code in there-in between the corresponding tags of course. Link to comment Share on other sites More sharing options...
davej Posted December 1, 2013 Share Posted December 1, 2013 Will Php execute inside a .html file? I didn't think it would unless trickery is used... http://php.about.com/od/advancedphp/p/html_php.htm This is not the same as my recent question... http://w3schools.invisionzone.com/index.php?showtopic=48965 Link to comment Share on other sites More sharing options...
dsonesuk Posted December 1, 2013 Share Posted December 1, 2013 mod rewrite is used to not show php or change extension to show .htm/l instead in most cases. Link to comment Share on other sites More sharing options...
aloniie Posted December 1, 2013 Share Posted December 1, 2013 You cannot execute a PHP script in a .html file. You might have seen websites like http://example.com/page/home.html, they simply use mod url rewrite for that. Link to comment Share on other sites More sharing options...
Hadien Posted December 1, 2013 Share Posted December 1, 2013 i know is possible for php to directly parse in simple .html extensions, I just don't remember exactly how. I do remember certain frameworks, Zend specifically, created special new extensions like .phtml which php will run in, different from mod_rewrite which makes sure the browser doesn't show the ".php", ".html", or ".phtml". I don't know exactly why they don't simply allow .html extension to directly run PHP by default, but my guess would be certain things like compatibility, overhead, etc. Link to comment Share on other sites More sharing options...
justsomeguy Posted December 2, 2013 Share Posted December 2, 2013 When you configure the server to execute PHP for certain files, you also tell the servers which file extensions you want to use PHP to handle. Link to comment Share on other sites More sharing options...
davej Posted December 2, 2013 Share Posted December 2, 2013 So you can tell the server to do whatever to whatever? Is there some point to this? Link to comment Share on other sites More sharing options...
thescientist Posted December 2, 2013 Share Posted December 2, 2013 is that a rhetorical question? Link to comment Share on other sites More sharing options...
davej Posted December 2, 2013 Share Posted December 2, 2013 Well, I mean what is this seemingly devious stuff intended to accomplish? Link to comment Share on other sites More sharing options...
justsomeguy Posted December 2, 2013 Share Posted December 2, 2013 What if you have a website that you've been optimizing on search engines for years, with links all over the internet. Say, for example, a website that has a bunch of online tutorials that people link to. What if you decide that you want to change the underlying architecture of the site because you've found a more powerful and more efficient way to do everything? What if that architecture change includes a change in the server-side language that you're using? Are you going to change every single URL on your site so that all of your old search-engine-ranked URLs no longer point to the correct content? Are you going to mess around with redirecting the entire old site to the new site? How about just setting up the server so that it uses the new language to handle the old URLs? That's just one example, of course. There could be any number of reasons for doing something like that. Maybe you want a language-independent URL, like Google uses, so that you can change your languages without changing your URLs. Maybe you want to use custom file extensions for whatever reason. Maybe you're Microsoft running outlook.com and you want .srf files to be handled by a specific application. Maybe you just want to hide the technologies that your server is using for security reasons. There are an infinite number of reasons why someone might want to do something. Software developers typically don't seek out all of those reasons. Some are valid, maybe some are pointless. That's not a reason to not have a certain option in your application. If it is possible (and, actually, necessary) to define a set of extensions that various application mappings can handle, then why wouldn't a system administrator have the ability to add any extension to any application mapping? Why would the person developing the web server application prohibit the admin from doing that? Can you think of a single example why that ability should be artificially restricted when there's not a technical reason to restrict it? Link to comment Share on other sites More sharing options...
softweb001 Posted December 3, 2013 Share Posted December 3, 2013 hi guyz..please i want to hide my .php extension but i couldn't can you please help me out Link to comment Share on other sites More sharing options...
thescientist Posted December 3, 2013 Share Posted December 3, 2013 hi guyz..please i want to hide my .php extension but i couldn't can you please help me out please start a thread for your question with what you have tried so far and what you're stuck on Link to comment Share on other sites More sharing options...
davej Posted December 5, 2013 Share Posted December 5, 2013 Ok, so it is done for security or bookmarking or search-engines. I just wanted to understand why you might want to do that. Link to comment Share on other sites More sharing options...
softweb001 Posted December 10, 2013 Share Posted December 10, 2013 please am new in this forum and i dont understand or know how to start a thread can you expalin better or give me a link to guide me through..............thanks Link to comment Share on other sites More sharing options...
justsomeguy Posted December 10, 2013 Share Posted December 10, 2013 When you're looking at the list of threads, there is a black Start New Topic button on the top and bottom of the page. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now