Page 1 of 1
method and function
Posted: Fri Aug 28, 2009 11:45 pm
by ranjitbd
question 1.what is the difference between function and method in a php code...
question 2.
what is the difference between between two following declaration
$abc;
var $abc;
Re: method and function
Posted: Sat Aug 29, 2009 12:09 am
by requinix
A function (or "subroutine") is
a generic term. A method is
a function that belongs to a class.
sprintf and
mysqli_query are functions,
DateTime::add and
mysqli::query are methods.
$abc; is not a declaration. PHP does not have those for regular global variables.
var $abc; declares a member variable of a class. It is a PHP 4 feature (see
this) and was replaced with
public in PHP 5.