Can someone explain to me what the difference between
include_once 'classb.php'
class A
{
$a = new B
}
and
class A extends B
{
$a = new B
}
is?
What advantages/disadvantages are there to extending a class vs. including the .php file?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Your
include_oncereads in a source file, which in this case presumably has a class definition forBin it. Yourextendssets up classAas inheriting classB, i.e.Agets everything inBand can then define its own modifications to that basic structure. There isn’t really any relationship at all between the two operations, and your$a = new Boperations are nonsensical (not to mention syntax errors).