class Patient {
protected static $table_name = "siteA";
public $id;
public $first_dx;
public $confidence;
public $second_dx;
public $path_dx;
public function __construct(){
self::$table_name = $_SESSION['user_site'];
}
}
Basically a constructor is a magic method that will be the first thing to execute when creating a new instance of your object, which is a perfect candidate for initializing values.
The reason you cannot use $_SESSION['user_site']
in the declaration of the properties is because they are being created at compile time where the session doesn't yet exist.