public static function go($string) { preg_match("/{((.*?)::(.*?))}/s", $string, $match); if (sizeof($match) > 0) { if (is_callable($match[1], false, $callable_name)) { $result = call_user_func($match[1]); } else { $result = ClassUtil::getStaticVal($match[2], $match[3]); } } return $string = str_replace($match[0], $result, $string); }
public static function hostConnect($database = "{database}") { //---------------------------------------------------------- //init var //---------------------------------------------------------- $class = "Constants"; //---------------------------------------------------------- $chk = self::constCHK($database); //---------------------------------------------------------- if (!$chk['bool']) { return $chk; } else { $database = $chk; } //---------------------------------------------------------- if (is_null(Constants::$mysqli) || !($chk = Constants::$mysqli->select_db($database))) { //------------------------------------------------------ if (is_null($mysqli)) { $mysqli = new mysqli(ClassUtil::getStaticVal($class, "host"), ClassUtil::getStaticVal($class, "user"), ClassUtil::getStaticVal($class, "pass")); } //------------------------------------------------------ if ($mysqli->connect_error != null || $mysqli->host_info == null) { $chk = array("result" => $mysqli, "error" => true, "bool" => false, "host_info" => !Constants::$debug ? NULL : $mysqli->host_info, "message" => $mysqli->connect_error); if (!Constants::$debug) { $chk["loginInfo"] = array("host" => ClassUtil::getStaticVal($class, "host")); } return $chk; } //------------------------------------------------------ Constants::$mysqli = $mysqli; } //---------------------------------------------------------- Constants::$mysqli->select_db($database); //---------------------------------------------------------- if (Constants::$mysqli->error != null) { $chk = array("result" => Constants::$mysqli, "error" => true, "bool" => false, "message" => Constants::$mysqli->error); if (!Constants::$debug) { $chk["loginInfo"] = array("host" => ClassUtil::getStaticVal($class, "host")); } return $chk; } //---------------------------------------------------------- return Constants::$mysqli; }