Basic Variable Problem


I have the following code: <?php x = 1; ?>

I receive the following error: Parse error : syntax error, unexpected ‘=’ in /volume1/web/test2.php on line 1

I -assume- this is a problem with my configuration somehow… ? But I can’t find the problem. :frowning:



1 Like

Hello and welcome to PHPHelp,

the error is telling you that php cannot assign the value 1 to the letter x because the equals sign is an assignment operator in need of a valid data item.

so you need to use a dollar sign to create a variable named x:

$x = 1;

1 Like