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 |
what the new feature add in php 7.2?
This question is regarding version control. If two developers are committing the same php file at same time what will happen ? What error it will show (if any) ?
What is the use of strpos in php?
Where is session value stored php?
What is difference between md5 and SHA256?
does PHP support foreign key and Rollback?yes or not.if not then why. how will you done these concept in php?
1 Answers Avanigoradia, Primus Global,
How I can control asset documents without GR/IR?
0 Answers i2U Systems, Industrial Hand Protection, Mutha Technosoft,
Tell me in php, objects are they passed by value or by reference?
What are the rules in creating php variable?
Tell me what is the difference between characters 34 and x34?
What is the use of Mbstring?
What is symfony php?