Thursday, December 10, 2009

How to produce a system beep with PHP.

/**
* This will not do anything when running through a browser,
* if running through a shell it will produce an audible beep $int_beeps times.
* This should work on Windows, Unix, etc.
* @param
* @return
*/
function beep($int_beeps = 1) {
for ($i = 0; $i < $int_beeps; $i++): $string_beeps .= "\x07"; endfor;
isset ($_SERVER['SERVER_PROTOCOL']) ? false : print $string_beeps;
}

No comments: