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
https://forums.phpfreaks.com/topic/287995-syntax-issue/
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?

Link to comment
https://forums.phpfreaks.com/topic/287995-syntax-issue/#findComment-1477196
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
https://forums.phpfreaks.com/topic/287995-syntax-issue/#findComment-1477198
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.