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
How do I run php?
How to get the number of characters in a string?
Write a program to find no of days between two dates in php?
How we can get the number of elements in an array?
Do you know what is the differences between $a != $B and $a !== $B?
How will you calculate days between two dates in PHP?
Why are sessions used?
Name some of the constants in php and their purpose.
How to retrieve the original query string?
What is the different between count() and sizeof() in php?
How to initiate a session in php?
Tell me are parent constructors called implicitly inside a class constructor?
What are getters and setters and why are they important?
What is php.ini & .htacess file?
What are php expressions?