943,954 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 394
  • PHP RSS
Jul 22nd, 2009
0

Please help me with this very basic variables question...

Expand Post »
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 Syntax (Toggle Plain Text)
  1. <?php
  2.  
  3. # This script demonstrates how to
  4. # create a numeric array.
  5.  
  6. @AcmeInventory = (178,286,387);
  7.  
  8. print "$AcmeInventory[0]<br>\n";
  9. print "$AcmeInventory[1]<br>\n";
  10. print "$AcmeInventory[2]<br>\n";
  11.  
  12. print "<p>We just created a list of numbers using an array variable!";
  13.  
  14. ?>

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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
mbirame is offline Offline
34 posts
since Apr 2009
Jul 22nd, 2009
0

Re: Please help me with this very basic variables question...

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 $AcmeInventory = (178,286,387); .

EDIT: If that doesn't work, change that line to this:
$AcmeInventory = array(178,286,387); .
Last edited by humbug; Jul 22nd, 2009 at 11:13 pm. Reason: added note
Reputation Points: 20
Solved Threads: 13
Junior Poster in Training
humbug is offline Offline
93 posts
since Oct 2005
Jul 22nd, 2009
0

Re: Please help me with this very basic variables question...

thank you!
Reputation Points: 10
Solved Threads: 0
Light Poster
mbirame is offline Offline
34 posts
since Apr 2009
Jul 22nd, 2009
0

Re: Please help me with this very basic variables question...

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?
Reputation Points: 10
Solved Threads: 0
Light Poster
mbirame is offline Offline
34 posts
since Apr 2009
Jul 23rd, 2009
0

Re: Please help me with this very basic variables question...

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.
Reputation Points: 20
Solved Threads: 13
Junior Poster in Training
humbug is offline Offline
93 posts
since Oct 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: error with base64_decode returning the data instead of the images
Next Thread in PHP Forum Timeline: PHP sessions





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC