Php – How to pass php variable into a class function

functionphpvariables

I want to pass php variable $aa into a class function. I have read some articles
in php.net, but I still don't understand well. Can anyone help me put the variable into this class? thanks.

$aa='some word';
class Action {
    private $_objXML;
    private $_arrMessages = array();
    public function __construct() {        
        $this->_objXML = simplexml_load_file($aa.'.xml');
    }
}

Best Solution

Simply put the variable names in the constructor.

Take a look at the snippet below:

public function __construct( $aa )
{
   // some content here
}