PHannum Posted April 24, 2014 Share Posted April 24, 2014 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! Quote Link to comment https://forums.phpfreaks.com/topic/287995-syntax-issue/ Share on other sites More sharing options...
Jacques1 Posted April 24, 2014 Share Posted April 24, 2014 What's that lonely comma string doing there? Is it a separate method argument? Then you need a comma after it. Is it supposed to belong to the time? Then you need string concatenation. But you can't just put it there with no context. Quote Link to comment https://forums.phpfreaks.com/topic/287995-syntax-issue/#findComment-1477190 Share on other sites More sharing options...
bsmither Posted April 24, 2014 Share Posted April 24, 2014 Here is your argument list: put($name, $value, $expiry) And this is your call: put($name, ',' time() - 1) Methinks the second argument, for $value, perhaps being an empty string, has the comma in the wrong place. Quote Link to comment https://forums.phpfreaks.com/topic/287995-syntax-issue/#findComment-1477192 Share on other sites More sharing options...
PHannum Posted April 24, 2014 Author Share Posted April 24, 2014 Please elaborate? Quote Link to comment https://forums.phpfreaks.com/topic/287995-syntax-issue/#findComment-1477194 Share on other sites More sharing options...
Jacques1 Posted April 24, 2014 Share Posted April 24, 2014 (edited) 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 April 24, 2014 by Jacques1 Quote Link to comment https://forums.phpfreaks.com/topic/287995-syntax-issue/#findComment-1477196 Share on other sites More sharing options...
gizmola Posted April 24, 2014 Share Posted April 24, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/287995-syntax-issue/#findComment-1477198 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.