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 constructor
What is composer json?
Is PHP runs on different platforms (Windows, Linux, Unix, etc.)?
How do I check if a given variable is empty?
Can we use php variable in javascript?
How to protect special characters in query string?
What is Different between Joomla And Magento?
How do you define a constant?
What is member variable?
What is the use of "echo" in php?
Why sessions are used in php?
Is java is better than php?
What is php stack?
What is $_ files in php?
What are the difference between abstract class and interface in oops?