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

in PHP for pdf which library used?

1015


For image work which library is used in php?

995


What is $_ post in php?

1078


How many open modes available when a file open in PHP?

1166


What is the differences between $a != $B and $a !== $B?

1075


What is the difference between include and require?

1001


What is an array in php?

1145


How do functions work?

1114


What are the new features available in php 7?

998


Is php a framework?

959


Explain about getters and setters in php?

1068


What is the best way to avoid email sent through php getting into the spam folder?

994


How to move uploaded files to permanent directory?

962


What is the function file_get_contents() useful for?

940


What is trait in php?

974