Q:

php: how to make a method inside a class run? 

I started learning oop php and I don't understand how to make a method inside a class execute. 
This is the code:
class GrabData {
public $tables=array();
public $columns=array();
public $argList;

function __construct(){
    $this->argList=func_get_args();
    $pattern;
    var_dump($this->argList);
    if(!empty($this->argList)){

        foreach($this->argList as $value){
            if(preg_match("/.+_data/",$value,$matches)){
                if(!in_array($matches[0],$this->tables)){
                    array_push($this->tables,$matches[0]);
                    var_dump($this->tables);
                }
                $pattern="/".  $matches[0] . "_" . "/"; 
                array_push($this->columns,preg_replace($pattern,"",$value));
                var_dump($this->columns);
            }

        }
    }
}

public function gen_query(){
    var_dump($this->argList);
    echo "haha";
}

    gen_query();
}

new GrabData("apt_data_aptname");

Now, the __construct function runs when I make a new GrabData object, but the gen_query function doesnt execute.  How do I make it execute it ? 

A:

If you always want to have the gen_query function run when the class is initiated, you could link to it in the bottom of your constructor, like so:
function __construct() {
    // Do your stuff here and then...
    $this->gen_query();
}

