Friday, 6 February 2015

You Must Know Few Thinngs about Php :: For Beginner


How To Define Class in Php

The class keyword defines a class

class Book
{
}

How To Define Function in Php

The class keyword defines a class, just as function defines a function.
class Book {

function update($comment, $visitor) {
...
}
}

Difference Between global and local variable

Global
The variable is accessible from anywhere in the script
Llobal
The variable is only accessible from within the function (or method) that created it
class Book {

$gocalVariable = 1;

function update($comment, $visitor) { 
 
$localVariable = 1; 
 
}
}

Call Function using Object

class Book {

function update($comment, $visitor) {
...
}
}

$book = new Book;
$book->update("hello",5);


You Can also Call a method Without Creating a Object,mostly it is used for Static
Method but you can also use for normal method. 
 
Book::update("hello",5);



No comments:

Post a Comment