Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

what is constructor in a class, how it is work, how it is call?

Answer Posted / kapil dhiman

Constructor is a special function which is automaticaly called when object of the class is created.In php4 costructor having the same name of the class while in php5 costructor function declare like __construct(){ }.
<?
class MakeConstruct{

public function __construct(){

echo "php5 construct";

}


public function MakeConstruct(){

echo "php4 construct";

}

}

$obj= new MakeConstruct();

?>

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is mysqli_real_escape_string?

948


What is the difference between $name and $$name?

916


Is php free to use?

958


What's the difference between accessing a class method via -> and via ::?

1036


What is good average session duration?

960


What is an operator in php?

1006


How do you put a space in html?

946


How many types of session are there?

985


What is scope of variable in php?

999


Where can I learn php?

896


How can we encrypt the password using php?

1033


What is http php?

901


What is an example of a variable?

959


What is the difference between fopen() and fclose()?

1042


Explain how does one prevent the following warning ‘warning: cannot modify header information – headers already sent' and why does it occur in the first place?

939