Do not understand this new $people ();

there is a piece of php code that simulates the hook mechanism

    class Ball{  
          public $people;
          public function down(){  
            echo    "ball is downing ";  
            //  
            $this->people=new Hook();
            $this->people->add("man");  
            $this->people->add("woman");  
        }  
          
        public function do(){  
            $this->people->exec();  
        }     
      
    }  
      
    //   
    class Hook{  
        private $hooklist = null ;  
        //   
        public  function add($people){         
            $this->hooklist[] =  new $people();        
        }  
        //   
        public function exec(){  
            foreach($this->hooklist as $people){  
                  $people->act();
            }  
              
        }  
    }  
    //   
    class man{  
        public function act(){  
            echo "nothing";  
        }     
    }  
      
    class woman{  
        public function act(){  
            echo "oh my god ";  
        }     
    }  
      
      
    $ball = new Ball();  
    $ball ->down();  
    $ball ->do();  
    

new $people()
people


        public  function add($people){         
        $this->hooklist[] =  new $people();        
    }  
Php
Jan.19,2022

can't you see that people is preceded by a $, which means it's just a variable, but the value of this variable may be an instance of a function with the new operation


$people = 'man'; , new $people (); is equivalent to new man ();

$people = 'woman'; , new $people (); is equivalent to new woman ();

Menu