function getSvgIcon($path, $class = "") {
$rootPath = "www/site/"; // project path
$full_path = $rootPath . $path;
if ( !file_exists($full_path) ) {
return "<!--SVG file not found: $path-->\n";
}
$cls = array("svg-icon");
if ( !empty($class) ) {
$cls = array_merge($cls, explode(" ", $class));
}
$svg_content = file_get_contents($full_path);
$output = "<!--begin::Svg Icon | path: $path-->\n";
$output .= "<span class=\"".implode(" ", $cls) . "\">" . $svg_content . "</span>";
$output .= "\n<!--end::Svg Icon-->";
return $output;
}
<?php
echo getSvgIcon('assets/media/icons/duotune/abstract/abs010.svg', 'svg-icon-2x svg-icon-success');
?>