Hi folks,
I am brand new to PHP, but I am trying to learn from an online tutorial. I'm using this one:
http://inpics.net/tutorials/php/variables24.html

I'm sure there are many others, but that's where I'm at now. I am on the variables section, and they present this code:

<?php

# This script demonstrates how to
# create a numeric array.

@AcmeInventory = (178,286,387);

print "$AcmeInventory[0]<br>\n";
print "$AcmeInventory[1]<br>\n";
print "$AcmeInventory[2]<br>\n";

print "<p>We just created a list of numbers using an array variable!";

?>

The problem is when I run this, I get this error:

Parse error: syntax error, unexpected '=' in /home/content/m/b/i/mbirame/html/PHPscripts/numberlist.php on line 7

I have PHP5 running on my server...have things changed in 5 to make me need different code for the variables?


Thank you!
Joel

Recommended Answers

All 4 Replies

It seems there is an error in the tutorial you are using. the "@" symbol is actually used to suppress an error that the following function might throw: http://www.tuxradar.com/practicalphp/19/8/12

I'm assuming the author ment that to be a "$" symbol, as that indicates a variable. that line should be [b]$[/b]AcmeInventory = (178,286,387); .

EDIT: If that doesn't work, change that line to this: $AcmeInventory = [B]array[/B](178,286,387); .

thank you!

Yes-I had to include the "array" as well...strange, could this have been for an old version of PHP or just a bad tut?

I'm assuming it's just a bad tut because of the lack of attention to detail and testing. The @ symbol was never for variables.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.