I’m quite new to PHP Classes and I’m currently setting up a couple of Class Variables as shown below. The .time() function fails – third line below. If I remove the .time() it works.
class session {
private $variable;
private $cookieExpiry = time() + 15811200; // Cookie Expire
function __construct() {
Are you not allowed to set a variable like this with a default php function?
Is there a way to do this?
thankyou
The properties are a blueprint and must be independent of the runtime environment. You can set them to literal values but you can’t make function calls like that. Set the initial properties in the constructor: