JavaScript-like events for PHP