...

View Full Version : Understanding PHP



Kev0121
03-02-2009, 12:38 AM
Right, so i've been learning about php for 6 months now and i still don't know how it works and i've been told this is my down to it. So is there anywhere, where i can learn how it works so i can get the "programming flow"

/Kev

Fou-Lu
03-02-2009, 12:49 AM
Can you elaborate on what you mean by how it works? Are you asking how the interpreter passes data back and forth between C, or are you asking how the flow of a web page would go?

Kev0121
03-02-2009, 12:51 AM
The flow of a web page i guess lol i've been told that i need to know "how programs flow"

Fou-Lu
03-02-2009, 01:06 AM
Ok.
PHP is procedural. Starting with PHP5, they have adopted a strong interpreted object core allowing collection of properties into new data types. PHP is otherwise a datatype weak language, forcing the developer to make the necessary checks to conform the input data. All input data is a typeof string from a form, which is why PHP uses weak datatyping.
Procedural programming involves moving from the start of the program to the end of the program, executing each command one by one. Developers write sub-routines to break from the normal procedural flow - these are called functions in php. PHP has hundreds of pre-defined functions, including extensions.

There is no pre-set method of generating or handling data on a website. The only thing that matters is that header data is sent prior to output. This is done by ensuring any method that requires headers (header, cookies, sessions, etc) are handled before the first echo/print command including die and exit. With this in mind, cookie and session handling must occur before the printing.
A flow for an actual website happens when a client requests data from a server. The client in our example is a web browser, and the server is a web server (we'll use apache since it is more common, but IIS is quite similar too). Apache asks the requested resource what it should do with the it, and the resource tells apache to ask the PHPModule used for apache how to deal with it (this is the settype added in apache conf file). Apache sends the data to the module which takes the page, interprets what it needs to do, and sends a result to apache. Apache then sends this data back to the client, generally in HTML format (though can be of type CSS, Javascript for text examples, and jpeg, png for binary examples).

Is that what you're asking about?

Kev0121
03-02-2009, 01:14 AM
YES! thanks a lot, i understood


Procedural programming involves moving from the start of the program to the end of the program, executing each command one by one. Developers write sub-routines to break from the normal procedural flow - these are called functions in php. PHP has hundreds of pre-defined functions, including extensions.

This bit only lol

Kevin

Fou-Lu
03-02-2009, 01:26 AM
Ok, glad that helps!
If you have any specific usage questions, you can feel free to post a new thread and we'll try to help (different members have different and diverse usage skills, so combined we probably have PHP down to every function).

Kev0121
03-04-2009, 01:28 PM
What's the easiest way to understand and learn PHP is it reading a tutorial and actually doing a practical or just read and watch tutorials or?

Kevin

djm0219
03-04-2009, 02:33 PM
Working through tutorials and practice are the best way, IMO, of learning any language including PHP.

Yuen Biao
03-04-2009, 10:02 PM
What's the easiest way to understand and learn PHP is it reading a tutorial and actually doing a practical or just read and watch tutorials or?

Kevin

I'm not sure if we can post links, but two really good php resources I remember are hudzilla php guide and PHP101 is great for beginners. I think you can google for those easily.

borrad
03-04-2009, 10:51 PM
Learning is best with a lot of reading and practice in the same time. I know that from my experience.

Mark Johanson



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum