Jump to content

Syntax Issue


PHannum

Recommended Posts

I'm having trouble understanding this syntax error: 

 

Parse error: syntax error, unexpected T_STRING in /home/students/phannum/public_html/n413/ooplr/classes/Cookie.php on line 19

 

Here it is in my code, highlighted and bolded:

 

<?php

class Cookie {
public static function exists($name) {
return (issest($_COOKIE[$name])) ? true : false;
}
 
public static function get($name) {
return $_COOKIE[$name];
}
 
public static function put($name, $value, $expiry) {
if(setcookie($name, $value, time() + $expiry, '/')) {
return true;
}
return false;
}
 
public static function delete($name){
self::put($name, ',' time() - 1);
}
}
 
Anything to help would be awesome!
Link to comment
Share on other sites

Take a close look at the erroneous line. You have a variable, then a comma, then a string with a comma in it and immediately after this a number. This is not valid PHP syntax.

 

As bsmither already pointed out, you probably wanted an empty string followed by a comma rather than a string with a comma in it.

 

That is, you want

 

'',

 

rather than

 

','

 

See the difference?

Edited by Jacques1
Link to comment
Share on other sites

Hi PHannum,

In the future, just use the code bbtag around your code blocks. Easier for everyone.

 

Hopefully between bsmither and jacques1, you can see that you need three params to your self::put() method call and you have only supplied 2, it appears by accident.

Link to comment
Share on other sites

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.