Never ever use jurchiks101 at gmail dot com code!!! It contains command injection vulnerability!!!
If you want to do it that way, use something like this instead:
<?php
if (PHP_OS === 'Windows')
{
exec(sprintf("rd /s /q %s", escapeshellarg($path)));
}
else
{
exec(sprintf("rm -rf %s", escapeshellarg($path)));
}
?>
Note the escapeshellarg usage to escape any possible unwanted character, this avoids putting commands in $path variable so the possibility of someone "pwning" the server with this code