Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Wondering why my variable doesn't increment inside of a function

 
Greenhorn
Posts: 9
PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I'm new to PHP and to functions, so I'm a bit confused as to why my variable isn't incrementing inside of a function.

Here's what I basically have:



But the echo $atriskbanks prints a 0, which is what I initialized the variable to earlier. So it's definitely not incrementing. ($ratio>75 is true in this case. $ratio is 100 point something).

Does anyone know why this variable isn't incrementing when I call the function?

Thank you very much for any thoughts you may have about this.
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Brenda, this page should explain what the problem is and how to fix it: https://www.php.net/manual/en/language.variables.scope.php
 
Let nothing stop you! Not even this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic