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

Reply

Join Date: Apr 2009
Posts: 29
Reputation: mbirame is an unknown quantity at this point 
Solved Threads: 0
mbirame mbirame is offline Offline
Light Poster

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

 
0
  #1
Jul 22nd, 2009
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:
  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
Reply With Quote Quick reply to this message  
Join Date: Oct 2005
Posts: 93
Reputation: humbug is an unknown quantity at this point 
Solved Threads: 13
humbug's Avatar
humbug humbug is offline Offline
Junior Poster in Training

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

 
0
  #2
Jul 22nd, 2009
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
"If your not having fun, your doing something wrong." - Humbug
★ Did I help you out? Did I piss you off? Add to my reputation!
The Gabriel Method is a great book for losing weight and keeping healthy - I know Jon Gabriel Personally.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 29
Reputation: mbirame is an unknown quantity at this point 
Solved Threads: 0
mbirame mbirame is offline Offline
Light Poster

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

 
0
  #3
Jul 22nd, 2009
thank you!
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 29
Reputation: mbirame is an unknown quantity at this point 
Solved Threads: 0
mbirame mbirame is offline Offline
Light Poster

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

 
0
  #4
Jul 22nd, 2009
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?
Reply With Quote Quick reply to this message  
Join Date: Oct 2005
Posts: 93
Reputation: humbug is an unknown quantity at this point 
Solved Threads: 13
humbug's Avatar
humbug humbug is offline Offline
Junior Poster in Training

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

 
0
  #5
Jul 23rd, 2009
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.
"If your not having fun, your doing something wrong." - Humbug
★ Did I help you out? Did I piss you off? Add to my reputation!
The Gabriel Method is a great book for losing weight and keeping healthy - I know Jon Gabriel Personally.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC