Oops there... functions that take strings as an argument should be provided strings, which are quoted (preferably double quotes, however PHP does handle single quotes)
use
exec("ping localhost");
if you need the output, consider using
passthru ("/somewhere/bin/blah etc etc");
Actually I'm suprised exec(ping) actually works.