ShaolinF Posted November 30, 2009 Share Posted November 30, 2009 Hi Guys, I have a function in my class which returns a string link variable. The problem is it keeps giving me a parse error. See code below followed by error message: function get_previouspage_link() { if($this->CURRENT_PAGE > 1) $previous_page = $this->CURRENT_PAGE - 1; return "$_SERVER['REMOTE_URI']?currentpage=$previous_page"; } Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in C:\wamp\www\wordpress\wp-content\themes\alburujpress\paginate.php on line 50 LINE 50: return "$_SERVER['REMOTE_URI']?currentpage=$previous_page"; Quote Link to comment https://forums.phpfreaks.com/topic/183418-parse-error/ Share on other sites More sharing options...
play_ Posted November 30, 2009 Share Posted November 30, 2009 function get_previouspage_link() { if($this->CURRENT_PAGE > 1) { $previous_page = $this->CURRENT_PAGE - 1; return "$_SERVER['REMOTE_URI']?currentpage=$previous_page"; } } Quote Link to comment https://forums.phpfreaks.com/topic/183418-parse-error/#findComment-968137 Share on other sites More sharing options...
JonnoTheDev Posted November 30, 2009 Share Posted November 30, 2009 <?php function get_previouspage_link() { if($this->CURRENT_PAGE > 1) { $previous_page = $this->CURRENT_PAGE - 1; } return $_SERVER['REMOTE_URI']."?currentpage=".$previous_page; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/183418-parse-error/#findComment-968139 Share on other sites More sharing options...
ShaolinF Posted November 30, 2009 Author Share Posted November 30, 2009 None of those worked until I changed the return statement to: return $_SERVER['REMOTE_URI'] . "?currentpage=$previous_page"; Quote Link to comment https://forums.phpfreaks.com/topic/183418-parse-error/#findComment-968156 Share on other sites More sharing options...
zeodragonzord Posted November 30, 2009 Share Posted November 30, 2009 Enclose your variables with curly brackets if inside quotes. function get_previouspage_link() { if($this->CURRENT_PAGE > 1) $previous_page = $this->CURRENT_PAGE - 1; return "{$_SERVER['REMOTE_URI']}?currentpage={$previous_page}"; } Quote Link to comment https://forums.phpfreaks.com/topic/183418-parse-error/#findComment-968282 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.