Array of objects within class in PHP

后端 未结 6 1922
没有蜡笔的小新
没有蜡笔的小新 2020-12-22 04:52

I recently realized my currently approach on a project would greatly improve with the use of better/more descriptive objects. As such, I realized that I want an array of obj

6条回答
  •  遥遥无期
    2020-12-22 05:33

    Just create another public variable for matches. Then, you can initialize it as an array in the constructor method.

    class LogFile
    {
        public $formattedMatches;
        public $pathToLog;
        public $matchCount;
        public $matches;
    
        function __construct() {
            $matches=array();
            //Load $matches with whatever here
        }
    }
    

提交回复
热议问题