Showing posts with label Introduction. Show all posts
Showing posts with label Introduction. Show all posts

Saturday, September 6, 2008

PHP 101

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.

Welcome

I have a couple blogs. This one, and a different one I'm semi-active in.

My other blog I own isn't really suited for lots of programming stuff, so instead of infest it with programming tutorials... I'm going to keep it more dedicated to general stuff.

This blog, on the other hand will be dedicated to programming/scripting.

Take everything I say in programming as opinion. I am not the inventor of programming languages, nor will I ever be. I am not the best on the internet, though I am pretty good at it.

I started in Grade 10 or 11 in Social Studies. I was kind of bored, and saw someone else making a website. I was intrigued that he was able to remember all these different symbols, and how to place them to make some things appear on the screen in certain ways.

I started to take a look at code on websites, and just little tutorials here and there. I took some of the lines out of the code, and put random stuff in just to see what would happen. That, my friends is how I started to learn HTML 4.

It seems that this era of kids/programmers mostly learn how to do things by trial and error. Riding bikes, you sit on a bike and try going forward. Sure you might fall a couple times, but eventually you will learn how to ride without falling over.

That is what I did with Websites, I got on the bike and kept trying to pedal until I did it without falling. What I hope to accomplish with this blog is to help people learn how to make websites without falling over.

Keep checking back here, as I will try and post as often as I can.