Logo

PHP OOP - Classes Introduction *Don't let Hull see*

Comments

Avatar Rob-de-prop
06 Nov 2012 16:03
Interesting. I don't very much see the need of classes yet, though.
Avatar 11Drago
04 Nov 2012 06:08
This is interesting yet confusing.
Avatar Skittles
03 Nov 2012 17:04
Quoth purplepandafish:
I think Danny saw.


Indeed.
Avatar purplepandafish
03 Nov 2012 16:12
I think Danny saw.
Avatar HullBreach
03 Nov 2012 11:13
Since this was meant to be an introductory blog, it probably would have been a good idea to explain what object-oriented programming is and how it's useful. Without that foundation, it will make no sense to the individuals that OMS is so frequently chasing off his front lawn.

I always use the analogy of a car. A car is made of numerous objects (i.e. wheels, engine, doors, brakes, etc.). Each object has its own specific properties and functions. The car facilities the interaction between these objects. Let's take the engine "object" as the example:

Properties of the engine include rated horsepower, rated torque, size, etc. The primary function of the engine is to generate power for the car. In code, all this would be written like so:

Class Engine{

Public static size = 2.0;
Public HP = 0;
Public torque;
Private oxygen;
Private gasoline;
Private on = false;

Public function __construct(){
$this->on = true;
}

Private function __destruct(){
$this->on = false;

Public function generate_power(oxygen, gasoline){
//some important calculation
$this->power =
$this->torque =
}

}

It would be something along those lines, just more filled out.

The car would be considered a super object, since it contains the other objects. There are practically infinite ways those could all be implemented, based on the needs of the final product and the programming style of the developer.
Avatar LinkZelda
03 Nov 2012 07:52
I have never learned php before. But I somehow understood it.
Avatar Skittles
03 Nov 2012 05:42
Quoth Raisons du Coeur:
I thought this was a joke at first.
"phP OOP... DRY... Repeat..."


;)
Avatar Raisons du Coeur
03 Nov 2012 05:31
I thought this was a joke at first.
"phP OOP... DRY... Repeat..."
Avatar MetalHeart
03 Nov 2012 03:40
Tsk tsk tsk... (>^_^)> why do you make these if you know noobs will use it wrong? Steal it for that matter?
Home
Nintendo 3DS is ™ Nintendo Co. Ltd. This website is ©2009-2019 HullBreach Studios. All rights reserved. Members are responsible for their own content. No account information will be given to third-parties without your consent.