Fatal error: Using $this when not in object context
Не понимаю, в чём причина?
на getParam('a')
не ругается
а на getAllSegments()
почему-то ругается
index.php
use library\Url;
var_dump(Url::getParam('a'));
var_dump(Url::getAllSegments());
Url.php
class Url {
private $_url;
private $_segments;
private $_params;
public function __construct(){
$this->_url = $_SERVER['REQUEST_URI'];
$this->getSegmentsFormUrl();
$this->_params = $_GET;
unset($this->_params['url']);
}
protected static function getSegmentsFormUrl() {
$segments = explode('/', $_GET['url']);
if(empty($segments[count($segments)-1])) {
unset($segments[count($segments)-1]);
}
return $segments;
}
public static function getParam($paramName) {
return addslashes($_GET[$paramName]);
}
public static function getAllSegments() {
return $this->_segments;
}
}