Yo Guys, this thread is for all the php and javascript guys in the house. On this thread, I am going to assume that
you can already write some javascript and you are a regular coder. Now, my favorite IDE happen to be Notepad ++ and I am very fast with it because stuffs i create or download in php and ajax, once i find them useful, i convert them to reusable codes - so i am going to be discussing those techniques in here. As way of introduction, PHP is an Object-Oriented Language, But Javascript is not an OOP lang but it is composed of objects - i can't explain this here [out of focus] - but let's go on.
First What Are Classes?
These are modules that run in a separate memory space - they have their own internal memory, functions, and they don't class with each other - for instance i can say:
Virtual.php
class Jclass{
function Jclass() {$this->url="about:blank";}
function visitUrl() {, }
}
$naira=new Jclass();
$naira->url="http://www.nairaland.com/";
$google=new Jclass();
$google->url="http://www.google.com/";
$naira->visitUrl();
$googel->visitUrl();
Do not bother to run this demo - i am just tryin to show you what classes are about. Now i declared a class up in the script. Then i now went on
to create 2 copies (called instances) of the same class - one for google and one for nairaland.
Then i proceeded to call a function (called method) in the class to visit the urls. So the $naira variable creates a copy of the class in itself and keeps it
inside itself, and same for the $google variable. Later on in this thread - i am going to be featuring some of the classes i have in both javascript and php.
Meanwhile questions are expected and will be answered as appropriately as possible.
And remember, creation and usage of reasonable classes is one of the highest levels of programming - I stand to be corrected on this one. All top-programmers can create classes as far as I know - i am yet to meet one that cannot. However some languages like JAVA and C necessitate class creation even for beginners. But in javascript/php you can still write great codes without classes but your codes will be soooo looong and you will have problems with repeating them when u have another job to do.