Hi, I’m Manu.

I used to have a blog a couple of years ago. I have to admit that I missed it a little, so I decided to go back at it in 2014. I write about a bunch of different topics.

Why “plothole.net”? As defined on wikipedia,

a plot hole, or plothole is a gap or inconsistency in a storyline that goes against the flow of logic established by the story’s plot, or constitutes a blatant omission of relevant information regarding the plot, sometimes even contradicting itself. These include such things as unlikely behaviour or actions of characters, illogical or impossible events, events happening for no apparent reason, or, statements or events that contradict earlier events in the storyline.

This definition suits my life pretty well.

Here are a couple of links if you want to know more about me:

And last but not least, here is my resume.

Thanks for reading.

N.B. this site has been tested on the most recent versions of Safari and Chrome on Mac OS X, as well as Safari on iOS. If something seems broken on one of those browsers, shoot me an email. If you’re using another browser, I’m sorry. I don’t find fixing browser quirks very interesting, I do enough of it professionnally.

subtilités de PHP

aaahhh… les pointeurs… ça me manquait presque…

Je viens de découvrir une jolie subtilité de PHP qui nous a bien fait flipper parce que nos transaction ne fonctionnaient plus :

Global vars and references

Storing references to global variables inside a function is a problem, as a global var inside a function seems to be nothing but a local var containing a reference to the global. Confused? An example:

function something()
  global $someObjectRef;
  $someObjectRef =& new someClass();

If you do this and look at $someObjectRef from outside the function (after calling the “something()” function), you will find it as it was before calling the function (probably empty).

The thing is, by using the “global” keyword you create a local variable pointing to (containing a reference to) a global variable. But as soon as you store another references into this local variable (by doing the “$someObjectRef =&… “), it’s not pointing the the global anymore! You simply “redirect” your local var, not even touching the contents of the global. So, what to do?

To assign object refs to global vars inside a function, don’t use the “global” keyword! Instead use the $GLOBALS dict, like this:

function something()
  $GLOBALS['someObjectRef'] =& new someClass();

That way, after calling something() the global variable someObjectRef will contain a reference to the newly created object.

source : http://www.obdev.at/developers/articles/00002.html