Monday, March 11, 2013

parse_ini_file grief

I know that different versions of php can vary greatly, but this is ridiculous and exposes just how miserable it can be when trying to debug Php code.

I had parse_ini_file working perfectly well developing on my desktop mac. Not too difficult a task. Then I tried to deploy to the server and got this error:
Warning: file_get_contents('http://localhost/server-status'): failed to open stream: No such file or directory in /.../apachemon.php on line 183
Now strike me grievously but how am I supposed to spot the mistake here!? (hint: I am 100% certain the resource at "http://localhost/server-status" does exist) Did you spot it? At the time I grumbled and prodded and poked and extracted code segments attempting to test them in isolation.

And eventually, I figured it out.

Now I could be wrong on this, but I don't think I'm an idiot! I've debugged my fair share of code. But even when I structure my code well, implement a decent Logger, and test as best I know how, Php still has a myriad of ways to kick me in the butt.

Did you spot the bug yet?

On my desktop I'm running PHP 5.3.15 and on the server it's PHP 5.2.6. Is that such a big difference?

Now I think I'm actually starting to enjoy coding in php. At least, when it works! But for now, I think I know what my Php debugging catch-cry is:

"Good luck with that!"

Oh, and the bug, just in case you didn't spot it. Or should I say, the "bug":
I used single quotes but apparently it wanted double quotes

No comments:

Post a Comment