私はCodeIgniterのにライブラリとしてアップsettedこの単純なキャッシュクラスを得た:解析エラー:T_PAAMAYIM_NEKUDOTAYIM
<?php
class Easy_cache {
static public $expire_after;
static function Easy_cache()
{
if ($this->expire_after == '')
{
$this->expire_after = 300;
}
}
static function store($key, $value)
{
$key = sha1($key);
$value = serialize($value);
file_put_contents(BASEPATH.'cache/'.$key.'.cache', $value);
}
static function is_cached($key)
{
$key = sha1($key);
if (file_exists(BASEPATH.'cache/'.$key.'.cache') && (filectime(BASEPATH.'cache/'.$key.'.php')+$this->expire_after) >= time())
return true;
return false;
}
static function get($key)
{
$key = sha1($key);
$item = file_get_contents(BASEPATH.'cache/'.$key.'.cache');
$items = unserialize($item);
return $items;
}
static function delete($key)
{
unlink(BASEPATH.'cache/'.sha1($key).'.cache');
}
}
私は今、それを使用したい、コントローラに私はこれを使用していますので、(私はロードしていますautoload.php
経由ライブラリー):
class Main extends CI_Controller
{
public function __construct()
{
parent::__construct();
}
public function index()
{
$cache = $this->easy_cache;
if (!$cache::is_cached('statistics'))
{
$data = array('data' => $this->model_acc->count());
$cache::store('server_statistics', $data);
}
else
$data = array('this' => 'value');
$this->load->view('main', array('servers' => $this->servers->get()));
}
}
そして、私はこのエラーを取得しています:
Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM in [..]
Iグラムを二重点や静的関数に関連する何かがありますが、私はクラスの初心者ですから問題は何ですか?
'予期しないT_PAAMAYIM_NEKUDOTAYIM' in ... ...どこですか?あなたは指定された行をハイライトしてください。 –
There: 'if(!$ cache :: is_cached( 'statistics'))'です。 – Cyclone
'$ this-> easy_cache'はどこに定義されていますか? – MichaelRushton