I'm trying to make a contact form replacement script. Users are able to put [contact-form] in their text editor and a contact form will appear. The script below works fine...
function ubbreplace($text){
    if (strpos($text, "[contact-form]") !== false) {
       ob_start();
       include("contactform.php");
       $replace = ob_get_contents();
       ob_end_clean();
       $text = str_replace("[contact-form]", $replace, $text);
    }
    return $text;
}
... but not for my project. Some did not know how to fix the issue with my code, so I'm trying to find a replacement for this. Other code with the same effect.
What can I do to safely and user friendly replace [contact-form] with include("contactform.php")?
 
    