PHP: How to instantiate a class with arguments from within another class

后端 未结 6 572
死守一世寂寞
死守一世寂寞 2021-02-07 13:48

I am in a situations where i need to instantiate a class with arguments from within an instance of another class. Here is the prototype:

//test.php

class test
{         


        
6条回答
  •  野的像风
    2021-02-07 14:04

    You could use call_user_func_array() I believe.

    or you could leave the arguments list of the constructor, and then inside the constructor use this

    $args = func_get_args();
    

提交回复
热议问题