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
What is mysqli_real_escape_string?
What is the difference between $name and $$name?
Is php free to use?
What's the difference between accessing a class method via -> and via ::?
What is good average session duration?
What is an operator in php?
How do you put a space in html?
How many types of session are there?
What is scope of variable in php?
Where can I learn php?
How can we encrypt the password using php?
What is http php?
What is an example of a variable?
What is the difference between fopen() and fclose()?
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?