/** * Sets a config value * */ public function set_config($key, $val) { if (!is_null(self::$content)) { // $pattern = '%(config\[\''.$key.'\'\] = \')(.*)(\';)%'; // self::$content = preg_replace($pattern, '$1'.$val. '$3', self::$content ); $pattern = '%(config\\[\'' . $key . '\'\\] = )(\'?.*\'?)(;)%'; $type = gettype($val); if ($type == 'string') { $val = "'" . $val . "'"; } elseif ($type === 'boolean') { $val = $val ? TRUE : (int) FALSE; } self::$content = preg_replace($pattern, '${1}' . $val . '${3}', self::$content); return TRUE; } return FALSE; }