csplrj Posted July 13, 2007 Share Posted July 13, 2007 Parse error: syntax error, unexpected '&', expecting T_VARIABLE or '$' in /a/page1.php on line 121 I am getting the above error I have used & operator to pass the value by refrence. This works in PHP 5 but not in 4.4.2. Is that & operator is not availabe in PHP 4.4.2? Thanks in advance CSJakharia Link to comment https://forums.phpfreaks.com/topic/59756-parse-error-syntax-error-unexpected-expecting-t_variable-or-in-apag/ Share on other sites More sharing options...
pocobueno1388 Posted July 13, 2007 Share Posted July 13, 2007 Could you post the part of the code giving you the error? Link to comment https://forums.phpfreaks.com/topic/59756-parse-error-syntax-error-unexpected-expecting-t_variable-or-in-apag/#findComment-297017 Share on other sites More sharing options...
teng84 Posted July 13, 2007 Share Posted July 13, 2007 ya post the part of that code but maybe u use & instead of $ for the declaration of variable Link to comment https://forums.phpfreaks.com/topic/59756-parse-error-syntax-error-unexpected-expecting-t_variable-or-in-apag/#findComment-297020 Share on other sites More sharing options...
csplrj Posted July 13, 2007 Author Share Posted July 13, 2007 The code is foreach($row as &$value) This works on PHP 5 but not on PHP 4.4.2 Bye for now CSJakharia Link to comment https://forums.phpfreaks.com/topic/59756-parse-error-syntax-error-unexpected-expecting-t_variable-or-in-apag/#findComment-297028 Share on other sites More sharing options...
infid3l Posted July 13, 2007 Share Posted July 13, 2007 The code is foreach($row as &$value) This works on PHP 5 but not on PHP 4.4.2 Bye for now CSJakharia It's not available in 4.4.2. As of PHP 5, you can easily modify array's elements by preceding $value with &. This will assign reference instead of copying the value. Link to comment https://forums.phpfreaks.com/topic/59756-parse-error-syntax-error-unexpected-expecting-t_variable-or-in-apag/#findComment-297052 Share on other sites More sharing options...
csplrj Posted July 13, 2007 Author Share Posted July 13, 2007 Is there any turnaround to this Actually I am changing the value of the elements of the array. Is there any other way to achieve this? Thanks in advance CSJakharia Link to comment https://forums.phpfreaks.com/topic/59756-parse-error-syntax-error-unexpected-expecting-t_variable-or-in-apag/#findComment-297060 Share on other sites More sharing options...
csplrj Posted July 13, 2007 Author Share Posted July 13, 2007 Thanks I got turnaround we can use foreach($row as $key=>$value) instead of that & operator Bye for now CSJakharia Link to comment https://forums.phpfreaks.com/topic/59756-parse-error-syntax-error-unexpected-expecting-t_variable-or-in-apag/#findComment-297063 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.