Auto incrementation question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
fd ski
Forum Newbie
Posts: 3
Joined: Tue Jul 08, 2003 10:42 am

Auto incrementation question

Post by fd ski »

Relative newbie here... asp / perl background.. loving php now. It's so... elegant !!

Anyway... question as follows. Simple webpage here is the erroring script

$somearray["somevalue"]++;

Error stats that value is undefined ( cause it doesn't exists first time its hit ) but increments it fine as if it was zero from the get go.
So it does what i need, but i could skip error message in my HTML :)

Sorry if this is a dumb newb question... i'm still learning.

Thanks.

fd
User avatar
Wayne
Forum Contributor
Posts: 339
Joined: Wed Jun 05, 2002 10:59 am

Post by Wayne »

it just looks like your error handling is rather high

this is a temporary fix,
try

Code: Select all

@$somearrayї"somevalue"]++;

or you could change the level of error handling
fd ski
Forum Newbie
Posts: 3
Joined: Tue Jul 08, 2003 10:42 am

Post by fd ski »

that worked, thank you Wayne.

What does @$Value does ? I'm trying to find more info on @ but not much :( Something about documentation and treating everything that follows as a value, so basically it forces $value to have a value before it's incremented ?

Once again, thanks a bunch,
'
User avatar
discobean
Forum Commoner
Posts: 49
Joined: Sun May 18, 2003 9:06 pm
Location: Sydney, Australia
Contact:

Post by discobean »

you'll find the @ symbol when stuck infront of a function or expression dosn't return any errors or warnings..
Post Reply