This is one of the greatest OS (Open Source) tools widely available on the internet today. The simplicity of making websites with PHP is truly astounding if you think about it.
With the ever evolving PHP language, it becomes even better when a new version is released. Recently PHP 5.3.0 I think it was, was released. For those who want to explore can go here:
http://www.rooftopsolutions.nl/article/199
The main problem with PHP is that it's a very loose language in terms of coding practices. You can have the sloppiest code and it will still produce a web page. This is very bad if you didn't come from a Java or similar language background.
PHP has many similarities to C, and it also has some similiarties to Java.
For example, in order to do a function you go:
function Myfunction()
{
}
You also have something called reserved names. These "reserved names" are things used in PHP, or any other language that restrict you from using them as variables or function names.
So if I wanted to name my function 'function', you simple couldn't do that because PHP would generate an error.
I'm going to slowly integrate you in to OOP, and I will do very little with you in Procedural programming because I find it very in efficient for doing things in PHP 5.x+.
Before I continue, I will define for you Procedural programming and OOP.
OOP: OOP stands for Object Oriented Programming. It uses things like classes, and the classes themselves have functions grouped in to them.
Procedural Programming: This is a very simple way of writing your websites. You would write some code as your thinking it.
The Procedural way of making a website is ok in my books if you're doing one web page, and you don't need it for anything else. If you're making a more complicated website you will need to consider writing your web page with OOP.
This is what Procedural Programming looks like:
var $something;
var $something_else;
if ($something == $something_else)
{
echo "This is true";
} else {
echo "This is false";
}
?>
As you can see, we have that if statement there. Translating it in to human terms, it would be like "If something is equal to something else, then this is true. If it's not, this is false."
I am telling you that using the procedural code for one page is fine because you don't really need to reuse any code. When you are doing a big complicated system with registration, login pages, managing user accounts, etc. it wouldn't be obsured to think that you'd be writing hundreds of those if statements.
In OOP you wouldn't write many because you just reuse the code over and over again.
Enjoy this tutorial, it's not really going much in to how to do things yet... but you should hopefully be starting to get an idea of what PHP is.
Saturday, September 6, 2008
Subscribe to:
Post Comments (Atom)
2 comments:
Thank you for taking your time to make this tutorial! ^_^ This may be helpful to me in the future!
No problem,
I'm glad you enjoyed it :)
Post a Comment