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

后端 未结 6 571
死守一世寂寞
死守一世寂寞 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:07

    class textProperty
    {
        public $start;
        public $end;
        function textProperty($start, $end)
        {
            $this->start = $start;
            $this->end = $end;
        }
    
    }
    

    $object = new textProperty($start, $end);

    don't work?

提交回复
热议问题