val - recommanded to do it with compact() ex: create_html( "file.html", compact("var1","var2",) ); ex: create_html( array("file1.html", "file2.html"), array("var1"=>"value") ); @return a string of html code using ob_start() and ob_get_clean() allows to have php expansion inside the html loaded in opposition to the methode file_get_contents() https://stackoverflow.com/a/4402045/9497573 */ function create_html($files, $vars) { $files = (array)$files; $html_dir = plugin_dir_path(__DIR__).'html/'; extract($vars); ob_start(); foreach($files as $file) { include($html_dir.$file); } $html = ob_get_clean(); return $html; } ?>