Parse error: syntax error, unexpected ‘&’, expecting T_V

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ureshpatel5
Forum Newbie
Posts: 1
Joined: Thu Dec 24, 2009 4:15 am

Parse error: syntax error, unexpected ‘&’, expecting T_V

Post by ureshpatel5 »

Hi,
I am running same code over my sub domain and localhost successfully .
<Sub domain link : http://estate.alakmalak.net/list.php >

And i have upload it on another server it gives me such error.

Parse error: syntax error, unexpected ‘&’, expecting T_VARIABLE or ‘$’.....

<original link : http://www.theeverafterestate.com/secure/list.php >

Can anyone help why this error occur ?

ureshpatel5@gmail.com
Last edited by ureshpatel5 on Thu Dec 24, 2009 6:32 am, edited 1 time in total.
MichaelR
Forum Contributor
Posts: 148
Joined: Sat Jan 03, 2009 3:27 pm

Re: Parse error: syntax error, unexpected ‘&’, expecting T_V

Post by MichaelR »

You have a "&" sign where it shouldn't be on whatever line the error tells you. Try posting the code here. It'll be easier for us to help you.
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: Parse error: syntax error, unexpected ‘&’, expecting T_V

Post by McInfo »

The most likely scenario is that PHP 5 code is being run on a PHP 4 server. In PHP 4, accessing array elements by reference in a foreach loop will trigger the error. This is a valid syntax in PHP 5.

Code: Select all

foreach ($array as &$item);
See "Example #3 Collection" on this manual page.

Another scenario that triggers this error is

Code: Select all

$a = $&b;
For this, there are two possibilities:
  • The ampersand (&) is meant to come before the dollar sign ($) so the variable $b can be accessed by reference.
  • The ampersand is a typographical error.
In this scenario, the error appears differently depending on the PHP version:
PHP 4.4.8 wrote:Parse error: syntax error, unexpected '&', expecting T_VARIABLE or '$' in ... on line ...
PHP 5.2.8 wrote:Parse error: parse error, expecting `T_VARIABLE' or `'$'' in ... on line ...
Edit: This post was recovered from search engine cache.
Post Reply