PHP finally blocks not run on exit

I confirmed with the following code that if you call ‘exit’ withing a ‘try’ block the ‘finally’ block does *not* execute. That’s probably what you would expect. But now we know.

register_shutdown_function( 'handle_shutdown' );

try {

  exit;

}
catch ( Exception $ex ) {

  echo "caught...\n";

}
finally {

  echo "finally...\n";

}

function handle_shutdown() {

  echo "shutdown...\n";

}

Passing selected value into HTML select onchange handler

So you have a <select> element and you want to call a handler, but you need to pass the selected value to the handler because you have multiple instances of the same <select> and can’t access them by ID (because there is many, one of which will have the new selected value, but you don’t know which). The solution is to pass in the newly selected value, like this:

<select onchange='handle_change( this.value )'>

Easy-peasy!