the boogyman
New member
...function of a class ? Ok , I am trying to make sense of when to use a constructor or just a personal created FUNCTION in a CLASS in the PHP language to create an object... Ok , this is an example
class A
{
function __construct ($ y, $ x)
{
echo " The first parameter is ". $y."
";
echo " "The second parameter is" .$x."
";
}
}
a = new A ("First","Second");
Then with a normal other function named operations for example .
class A
{
function operation ($ y, $ x)
{
echo " The first parameter is ". $y."
";
echo " "The second parameter is" .$x."
";
}
}
a = new A ("First","Second");
MY QUESTION IS ... When do you have to use a constructor to create an object ... and when do you use a personally named function to create an object ?? can you use either one ??? I know __construct() is a built in function in PHP , so I wondered that it might have a special role of when it is used
Thanks !!!
class A
{
function __construct ($ y, $ x)
{
echo " The first parameter is ". $y."
";
echo " "The second parameter is" .$x."
";
}
}
a = new A ("First","Second");
Then with a normal other function named operations for example .
class A
{
function operation ($ y, $ x)
{
echo " The first parameter is ". $y."
";
echo " "The second parameter is" .$x."
";
}
}
a = new A ("First","Second");
MY QUESTION IS ... When do you have to use a constructor to create an object ... and when do you use a personally named function to create an object ?? can you use either one ??? I know __construct() is a built in function in PHP , so I wondered that it might have a special role of when it is used
Thanks !!!