PHP Doesn’t Play Nice


Unpunctual Programmer

On Friday I ran into a problem that very much looked like a bug in PHP. From what I can tell a function was not called that should have been. Here is an oversimplification of the code:

function foo() {
   ... some lines of code ...
   $this->bar()
   ... couple lines of code ...
   if(some stuff)
      error log that happened
   ... some more lines of code ...
}

function bar() {
   ... some lines of code ...
   error log that didn't happen
   $this->someState = a new state
   ... some lines of code ...
}

I ran this code once and the state of the class didn’t change and the error log line from bar() was not in the logs but the error log from foo() was in the logs. The error log in bar() isn’t any any kind of if or other flow control nor is there any place to return…

View original post 150 more words

Advertisements