what is constructor in a class, how it is work, how it is call?
Answers were Sorted based on User's Feedback
Answer / sei thu htun
Constructors are functions in a class that are automatically
called when you create a new instance of a class with new. A
function becomes a constructor, when it has the same name as
the class. If a class has no constructor, the constructor of
the base class is being called, if it exists.
| Is This Answer Correct ? | 5 Yes | 1 No |
Answer / 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 |
How will you create a bi-lingual site (multiple languages) ?
How to get the ip address of the client?
How to submit form without a submit button.
hello all, I need some sample placement papers in lion bridge.. can anyone help me?
Why ide is recommended for use while programming with php?
What is difference between html and php?
What does the unset() function mean?
how to add file in php?
What does explode do in php?
How can we submit a form without a submit button?
23 Answers ABC, HCL, Infosys, Kept Bug, Panys, Rushmore Consultancy, Torque Infotech, Wipro, zCon Solutions,
What are the benefits of using php?
write the prime number of program?in php