Instead of checking return values of every function and calling trigger_error() on failure, you can use a simpler alternative in the form of assert() that can accomplish the virtually the same with a lot less code.

<?php
function assert_c($file$line$msg)
{
    
trigger_error("Assertion '{$msg}' failed on {$file}:{$line}");
}
        
// call this on error
assert_options(ASSERT_CALLBACK'assert_c');

// do not warn on error
assert_options(ASSERT_WARNING0); 

// exit on error
assert_options(ASSERT_BAIL1); 

// ignore evaluation warnings
assert_options(ASSERT_QUIET_EVAL1); 

// check is user passed id is numeric
assert('is_numeric($_GET["id"])');
?>