Jump to content

[SOLVED] I hate to start a thread for this but... unexpected T_VARIABLE


Recommended Posts

The issue is isolated here:

 

public $folderCache = 'cache/';
public $secondsCache = 86400;
public $urlCache = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
public $fileCache = $this->folderCache.md5($this->urlCache).'.cache';

 

As the error still posts when open up that class file and that's the only thing in there. Even further, the error goes away then I delete:

 

public $urlCache = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
public $fileCache = $this->folderCache.md5($this->urlCache).'.cache';

 

Not either or, both of the deleted will make error go away. I know it's something small but I just can't see it. I even tried rewriting it just to make sure.

Most of what you wrote does not make sense.

 

"As the error still posts when open up that class file"

"Even further, the error goes away then I delete:"

"Not either or, both of the deleted will make error go away."

 

Can you please rewrite these? I'm sorry if English isn't your first language but it doesn't make sense.

 

Are you saying both of those lines give you the error? Post the whole error and the line that the line number refers to please.

I could be wrong, but I don't believe it's possible to declare members of a class as a variable value. It has to be a constant expression. I assume those values are being declared as members of a class, yes?

 

Edit: Yeah, that appears to be the case. Scroll to example 19.3.

Wow, still a little tired. Basically when I remove those two lines (and only those two lines. Not either/or but both), the error does not display. The code and error? ok

 

<?php
class cache{
public $folderCache = 'cache/';
public $secondsCache = 86400;
public $urlCache = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
public $fileCache = $this->folderCache.md5($this->urlCache).'.cache';

public function start(){
	$file_cache_exists = (@file_exists($this->fileCache)) ? @filemtime($this->fileCache) : 0;
	if ($file_cache_exists > time() - $this->secondsCache){
		@readfile($this->fileCache);
		exit();
	}
	ob_start();
}
public function finish(){
	$pointer = @fopen($this->fileCache, 'w');
	@fwrite($pointer, ob_get_contents());
	@fclose($pointer);
	ob_end_flush();
}
}
?>

 

Error: Parse error: syntax error, unexpected T_VARIABLE in /Applications/MAMP/htdocs/lastfm/new/lib/cache.class.php on line 5

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.