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
in PHP for pdf which library used?
For image work which library is used in php?
What is $_ post in php?
How many open modes available when a file open in PHP?
What is the differences between $a != $B and $a !== $B?
What is the difference between include and require?
What is an array in php?
How do functions work?
What are the new features available in php 7?
Is php a framework?
Explain about getters and setters in php?
What is the best way to avoid email sent through php getting into the spam folder?
How to move uploaded files to permanent directory?
What is the function file_get_contents() useful for?
What is trait in php?