template = $template; // Convert echo statements. $content = preg_replace('!\{([^{}]+)\}!', '', $content); // Remove spaces before and after all PHP tags, in order to maintain clean alignment. $content = preg_replace([ '!(?<=^|\n)([\x20\x09]+)(<\?(?:php\b|=))!', '!(\?>)([\x20\x09]+)(?=$|\r|\n)!', ], ['$2', '$1'], $content); return $content; } }