Page 1 of 1
Question about PHP Pages and Extensions
Posted: Fri Aug 15, 2008 11:05 pm
by Audioicon
I'm a confused. This is what I know so far. If you are saving a PHP page you need to add the PHP extension. Eg: index.php
Well,you can also embed PHP into HTML/XHTML but what extension do you use?
So if I create an XHTML/HTML page and had several php syntax/codes embeded into the page, will I need to save the page with an html or php extension?
PHP is a dynamic page right? You cannot preview PHP pages in a browser with out a server, t's a server side scripting language. So I need to hook up a local server on my computer like APACHE.
Let say I create an entire page with html but within that page I have a form I built using php?
How would I save this page? What would happen if I view this page in a regular browser? Will I only be able to see the HTML side?
Thanks for you help.
Patrick
Re: Question about PHP Pages and Extensions
Posted: Sat Aug 16, 2008 12:14 am
by Christopher
If it has PHP in it then it needs a .php extension. Did you try this yourself? There are only four possible combinations!
Re: Question about PHP Pages and Extensions
Posted: Sat Aug 16, 2008 1:08 am
by desmi
Just like Everah puts it:
http://www.robert-gonzalez.com/2007/06/ ... developer/
You dont really need our help to solve your question, you can try it out, thats the best way to learn too.
Re: Question about PHP Pages and Extensions
Posted: Sat Aug 16, 2008 11:07 pm
by califdon
Those responses are surely appropriate, but I can also see that beginners are confused by the very nature of how a preprocessor like PHP works. Therefore, I'll try to explain it for this requestor.
You're correct in your understanding of a server-side script, what you are missing is how it is actually processed by the web server. The server needs to know whether a file NEEDS to be preprocessed, and the common way to do that is by configuring the server to look at the file extension. That is how nearly all web servers are configured, although it is possible to tell a server to parse every file for PHP code. I'm sure you can see that in most installations that would be a lot of wasted cpu cycles. So the normal configuration is that Apache or whatever other web server we're talking about will only parse files for preprocessing if they have a .php extension. No doubt you can figure out the answers to the rest of your questions, once you understand what is going on.
Re: Question about PHP Pages and Extensions
Posted: Sun Aug 17, 2008 2:00 am
by Audioicon
califdon wrote:Those responses are surely appropriate, but I can also see that beginners are confused by the very nature of how a preprocessor like PHP works. Therefore, I'll try to explain it for this requestor.
You're correct in your understanding of a server-side script, what you are missing is how it is actually processed by the web server. The server needs to know whether a file NEEDS to be preprocessed, and the common way to do that is by configuring the server to look at the file extension. That is how nearly all web servers are configured, although it is possible to tell a server to parse every file for PHP code. I'm sure you can see that in most installations that would be a lot of wasted cpu cycles. So the normal configuration is that Apache or whatever other web server we're talking about will only parse files for preprocessing if they have a .php extension. No doubt you can figure out the answers to the rest of your questions, once you understand what is going on.
Thanks for you effort in answering my questions. I did read the response above, one day I'll have my own forum, it's just a matter of having the time to set one up. And people will not get scolded for asking questions, in fact, I'll strongly encourage people to asked anything.
I'm a professional audio engineer and I never try to insult or scold anyone if they need help or answers. If somebody asked a question about Mics, I'm not going to say, "just plug it and listen." If I don't want to answer someone's question, I'll just leave it alone.
But I'm not going to sit there because I know it all and got all my coding knowledge at birth and needed no one to help, so now I can take the time to scold someone for asking question in a place that is suppose to encourage people.
I'm sure there are many PHP resources out there, don't have to come here and put up with know it all attitudes.
Remember when I started learning CSS, had the same attitudes, now I know all I need to know to create a professional CSS/XHTML page. Now I take the time to help other people without scolding them.
Patrick
Re: Question about PHP Pages and Extensions
Posted: Sun Aug 17, 2008 3:52 am
by EverLearning
We're not scolding you. We're helping you grow.
Re: Question about PHP Pages and Extensions
Posted: Sun Aug 17, 2008 4:38 am
by desmi
Im sorry if you feel you got scolded, i was just telling you to test it by yourself, i'm happy to help you with anything, but i really think its much better for learning if you try to solve things first by yourself, then ask help if you cant solve it.