You can use the Built-In PHP function file_exists() to check if a file exists:
http://www.php.net/manual/en/function.file-exists.php
if(file_exists($content)) {
echo "exists";
} else {
echo "404";
}
However, keep in mind that if a user modifies your URL to have a ../ or even folder names, they could hack into files that they should be viewing. I recommend using:
$content = str_replace("/","",$content);
so that people can not view any files in any folders other than the current folder.
You may also want to make sure that people don't including your index.php, that would be bad 🙂
Hope this helps,
-Josh B