Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


what is constructor in a class, how it is work, how it is call?

Answers were Sorted based on User's Feedback



what is constructor in a class, how it is work, how it is call?..

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

what is constructor in a class, how it is work, how it is call?..

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

Post New Answer

More PHP Interview Questions

What are the encryption functions in php?

0 Answers  


Is php a dying language?

0 Answers  


What is the difference between pop3 IMAP and MAPI?

0 Answers  


How can you declare the array in php?

0 Answers  


How does php serialize work?

0 Answers  






What is php and sql?

0 Answers  


What do you mean by design patterns (php) ?

1 Answers   NIIT,


What is the purpose of the '.myi' file extension? What do thes file contain?

0 Answers  


Tell me how can we connect to a mysql database from a php script?

0 Answers  


Write a program to display table of a number using php?

0 Answers  


What is the difference between array_map () and array_shift ()?

0 Answers  


What is the scope of career in PHP/Mysql

34 Answers   Verizon, VGT,






Categories