@@ -295,6 +295,13 @@ public static function phpToMarkup($php, $charset = 'utf-8') {
295295 $ php = preg_replace ($ regex , '\\1<php><!-- \\3 --></php> ' , $ php );
296296 return $ php ;
297297 }
298+ /**
299+ * Converts document markup containing PHP code generated by phpQuery::php()
300+ * into valid (executable) PHP code syntax.
301+ *
302+ * @param string|phpQueryObject $content
303+ * @return string PHP code.
304+ */
298305 public static function markupToPHP ($ content ) {
299306 if ($ content instanceof phpQueryObject)
300307 $ content = $ content ->markupOuter ();
@@ -311,6 +318,7 @@ public static function markupToPHP($content) {
311318 array('<?php', '<?php', '?>', '?>'),
312319 $content
313320 );*/
321+ /* <node attr='<?php ?>'> */
314322 $ regexes = array (
315323 '@(<(?! \\?)(?:[^>]| \\?>)+ \\w+ \\s*= \\s*)( \')([^ \']*)(?:<|%3C) \\?(?:php)?(.*?)(?: \\?(?:>|%3E))([^ \']*) \'@s ' ,
316324 '@(<(?! \\?)(?:[^>]| \\?>)+ \\w+ \\s*= \\s*)(")([^"]*)(?:<|%3C) \\?(?:php)?(.*?)(?: \\?(?:>|%3E))([^"]*)"@s ' ,
@@ -970,7 +978,10 @@ public static function browser($ajaxSettings, $callback, $param1 = null, $param2
970978 }
971979 }
972980 public static function php ($ code ) {
973- return "<php><!-- " .trim ($ code )." --></php> " ;
981+ return self ::code ('php ' , $ code );
982+ }
983+ public static function code ($ type , $ code ) {
984+ return "< $ type><!-- " .trim ($ code )." --></ $ type> " ;
974985 }
975986}
976987/**
@@ -989,7 +1000,7 @@ public function __call($method, $args) {
9891000 array ($ realClass , $ method ),
9901001 $ args
9911002 );
992- return $ return
1003+ return isset ( $ return)
9931004 ? $ return
9941005 : $ this ;
9951006 } else
0 commit comments