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
Is it more secure to use cookies to transfer session ids?
Php program to generate fibonacci series?
What is the purpose of constant() function?
Is php 5 still supported?
What is smarty?
What is php form validation?
How does html form submit work?
Why do we use namespace in php?
What is the maximum size of a table in mysql?
How long is session timeout?
What are examples of independent and dependent variables?
Is php a dying language?
What is the difference between == and === operator in PHP?
Is php a programming language?
How to convert one date format into another in php?