phpQuery::phpToMarkup PHP Method

phpToMarkup() public static method

public static phpToMarkup ( $php, $charset = 'utf-8' )
    public static function phpToMarkup($php, $charset = 'utf-8')
    {
        $regexes = array('@(<(?!\\?)(?:[^>]|\\?>)+\\w+\\s*=\\s*)(\')([^\']*)<' . '?php?(.*?)(?:\\?>)([^\']*)\'@s', '@(<(?!\\?)(?:[^>]|\\?>)+\\w+\\s*=\\s*)(")([^"]*)<' . '?php?(.*?)(?:\\?>)([^"]*)"@s');
        foreach ($regexes as $regex) {
            while (preg_match($regex, $php, $matches)) {
                $php = preg_replace_callback($regex, array('phpQuery', '_phpToMarkupCallback'), $php);
            }
        }
        $regex = '@(^|>[^<]*)+?(<\\?php(.*?)(\\?>))@s';
        //preg_match_all($regex, $php, $matches);
        //var_dump($matches);
        $php = preg_replace($regex, '\\1<php><!-- \\3 --></php>', $php);
        return $php;
    }

Usage Example

 /**
  * Creates new document from markup.
  * Chainable.
  *
  * @param unknown_type $markup
  * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery
  */
 public static function newDocumentPHP($markup = null, $contentType = "text/html")
 {
     // TODO pass charset to phpToMarkup if possible (use DOMDocumentWrapper function)
     $markup = phpQuery::phpToMarkup($markup, self::$defaultCharset);
     return self::newDocument($markup, $contentType);
 }
All Usage Examples Of phpQuery::phpToMarkup