what is constructor in a class, how it is work, how it is call?
Answers were Sorted based on User's Feedback
Answer / sei thu htun
Constructors are functions in a class that are automatically
called when you create a new instance of a class with new. A
function becomes a constructor, when it has the same name as
the class. If a class has no constructor, the constructor of
the base class is being called, if it exists.
| Is This Answer Correct ? | 5 Yes | 1 No |
Answer / 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 |
Maine 12th ke bad 2 years ka web designing ka course kiya hai. Php me achcha hu. Ek fresher ko is field me kitna mil sakta hai ?
What does a delimiter do in mysql?
Will php die?
What is different types of visibility?
what is mean php ? is it designingtool or language? how ill create website using by php?
Php program to generate fibonacci series?
What is print_r?
Why is php used for web development?
Explain briefly about a search-friendly site looks like?
Is wordpress a php framework?
Explain Magento's autoload functionality and how to instantiate classes? What is the process you take when theming a store? Talk about Magento collections and how you use them?
List some features of php that are deprecated in php7?