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:

RTFM

https://www.php.net/manual/en/language.variables.basics.php

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;

https://www.php.net/manual/en/language.variables.php

1 Like
Sponsor our Newsletter | Privacy Policy | Terms of Service