Object Orientated core concept
We discussed Chars and Strings further up.
If you can understand the concept that Strings are groups of chars, you've got the basic idea behind OO.
Imagine further that I can create my own objects, and so I'll create one called Dog.
I'll also create one called Kennel (Pound in America?). Kennel might contain a list of the dog objects it knows about and wants to do something with. But it's important to understand the Kennel doesn't contain the ID for Dog (it can, but that's stupid), it contains the actual Dog object.
Everything is an object. Objects ONLY have properties and methods. Here's an example in PHP for simplicities' sake:
Code:
class Dog{
private $hair_colour;
private $gender;
function bark(){
//do a bark
echo "bark";
}
}
Ok, a couple of things above - most people have a standard for naming things, I've used a capitol D, never normally would, don't worry about it for now, it'll change.
// represents comments (in most langauges. /* */ for blocks of comments). use them OFTEN. your code isn't going to make sense in 5 minutes from now, let alone a week.
private (also public, protected, other keywords like static etc) not important at this moment. In PHP in particular you don't have to declare whether things are private or public.
Now I want to use this object:
Code:
$barney = new Dog();
$barney->gender = "not sure";
I've used the 'new' keyword to create a new dog who's a bit confused. '->' is the keyword in PHP to use or to access a property or function of the class we're discussing.