浏览代码

Add a is_xml function

FusionPBX 2 年之前
父节点
当前提交
383d965efb
共有 1 个文件被更改,包括 7 次插入0 次删除
  1. 7 0
      resources/functions.php

+ 7 - 0
resources/functions.php

@@ -159,6 +159,13 @@
 		}
 	}
 
+	if (!function_exists('is_xml')) {
+		function is_xml($string) {
+		    $pattern = '/^<\?xml(?:\s+[^>]+\s*)?\?>\s*<(\w+)>.*<\/\1>\s*$/s';
+		    return preg_match($pattern, $string) === 1;
+		}
+	}
+
 	if (!function_exists('recursive_copy')) {
 		if (file_exists('/bin/cp')) {
 			function recursive_copy($source, $destination, $options = '') {