Can A member of A class be declared using another class? does this function be required to assign values to this member? class
{
Var $ sun = '';
Var $ sav = false;
}
Class B
{
Var $ vo =;
Var $ tmp = 0;
}
Isn't that true?
So: class B
{
Var $ vo;
Var $ tmp = 0;
Function f ()
{
$ This-> vo = new;
}
}
In use:
$ Cls = new B;
$ Cls-> vo-> tmp = 1; // is this not acceptable? Using functions of class members?
Reply to discussion (solution)
$ Cls = new B; $ cls-> f (); // The value assigned by your vo attribute in this method! $ Cls-> vo-> tmp = 1;
Class B
{
Var $ vo = A; // This is incorrect!
Var $ tmp = 0;
}
$ Cls = new B; $ cls-> f (); // The value assigned by your vo attribute in this method! $ Cls-> vo-> tmp = 1;
$ Cls-> vo-> tmp = 1; // It seems impossible for me to test the assignment?
Class B
{
Var $ vo = A; // This is incorrect!
Var $ tmp = 0;
}
So: class B
{
Var $ vo;
Var $ tmp = 0;
Function f ()
{
$ This-> vo = new;
}
}
In use:
$ Cls = new B;
$ Cls-> f ();
$ Cls-> vo-> tmp = 1; // Can this be true? You must use the member function to assign values.
$ Cls = new B; $ cls-> f (); // The value assigned by your vo attribute in this method! $ Cls-> vo-> tmp = 1;
$ Cls-> vo-> tmp = 1; // It seems impossible for me to test the assignment?
Your code is probably wrong.
The following code is the same as your logic. it is executed and expected to have the same effect.
attrV = new A();}}$obj_b = new B();$obj_b->setAttrV();$obj_b->attrV->attrA = 'A';echo '$obj_b->attrV->attrA=' . $obj_b->attrV->attrA;
Thank you, everyone upstairs. there is a semicolon in the program!