-1

I'm working on this script and I'm trying to modify the payment system a bit to integrate authorize.net. Only problem is I need to find the declaration for some variables that I cannot seem to find yet are used throughout the script. How is this possible and is there a way to find out where they are declared?

halfer
  • 19,824
  • 17
  • 99
  • 186
dave
  • 14,991
  • 26
  • 76
  • 110
  • 5
    Because PHP will define a variable the first time it's referenced if it doesn't already exist: while it might be considered good practise to define a variable in advance of using it, it isn't mandatory – Mark Baker Apr 07 '15 at 21:55
  • ok makes sense...but what if the variable is an array and the code references indexes of the array without defining any of them yet? – dave Apr 07 '15 at 21:57
  • @date yes you can do that in php, array are very flexible – albanx Apr 07 '15 at 21:58
  • Same principle applies..... up the error level to display warnings and notices, and you might get some clues about what is and isn't defined – Mark Baker Apr 07 '15 at 21:58
  • im using phpstorm and the command "cntrl + click" seems to not find the declaration. – dave Apr 07 '15 at 21:58
  • http://stackoverflow.com/questions/4261133/php-notice-undefined-variable-and-notice-undefined-index – Clive Apr 07 '15 at 21:58
  • PHPStorm > right click the directory / project / find in path -> enter desired text. – N.B. Apr 07 '15 at 22:00
  • OK so let me ask you this...how is this logically possible: $paypal['status'] = 1. When $paypal hasn't been assigned and $paypal['status'] has never been assigned? By any chance the $paypal array being manipulated by reference anywhere? Cause thats the only other way i know that can manipulate a variable w/o declaring it...get me? – dave Apr 07 '15 at 22:05
  • and if a variable has never been assigned anything its value is '' by default correct? – dave Apr 07 '15 at 22:05
  • It's a programming language. Anything is "logically" possible, if the language designers allow it. Variables could be created at random, with random values, if people thought that would be useful. – dimo414 Apr 07 '15 at 22:06
  • ok keeping with respect to php.. – dave Apr 07 '15 at 22:06
  • at the example you brought at least some where $paypal=array(); – albanx Apr 07 '15 at 22:11
  • exactly my point! theres has to be a place where $paypal has been modified through reference or (re)declaration...otherwise how are those specific indexes with being initialized with values not default to php automatically assigning them... – dave Apr 07 '15 at 22:18

1 Answers1

-1

Okay, I figured it out. The only other way to instantiate/declare a variable without explicitly doing so is by PHP's variable variables feature. What was happening was the variables were being set by variable variables from a database query result.

Even though I should've provided more information/code possibly, someone should've have mentioned variable variables and assignment by reference.

halfer
  • 19,824
  • 17
  • 99
  • 186
dave
  • 14,991
  • 26
  • 76
  • 110