当前位置: 首页>>代码示例>>PHP>>正文


PHP PHPParser::arAllStr方法代码示例

本文整理汇总了PHP中PHPParser::arAllStr方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPParser::arAllStr方法的具体用法?PHP PHPParser::arAllStr怎么用?PHP PHPParser::arAllStr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PHPParser的用法示例。


在下文中一共展示了PHPParser::arAllStr方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: CheckForComponent2

 public static function CheckForComponent2($str)
 {
     if (substr($str, 0, 5) == "<?" . "php") {
         $str = substr($str, 5);
     } else {
         $str = substr($str, 2);
     }
     $str = substr($str, 0, -2);
     $bSlashed = false;
     $bInString = false;
     $arAllStr = array();
     $new_str = "";
     $string_tmp = "";
     $quote_ch = "";
     $i = -1;
     $length = strlen($str);
     while ($i < $length - 1) {
         $i++;
         $ch = substr($str, $i, 1);
         if (!$bInString) {
             if ($string_tmp != "") {
                 $arAllStr[] = $string_tmp;
                 $string_tmp = "";
                 $new_str .= chr(1) . (count($arAllStr) - 1) . chr(2);
             }
             //comment
             if ($ch == "/" && $i + 1 < $length) {
                 $ti = 0;
                 if (substr($str, $i + 1, 1) == "*" && ($ti = strpos($str, "*/", $i + 2)) !== false) {
                     $ti += 1;
                 } elseif (substr($str, $i + 1, 1) == "/" && ($ti = strpos($str, "\n", $i + 2)) !== false) {
                     $ti += 0;
                 }
                 if ($ti) {
                     $i = $ti;
                 }
                 continue;
             }
             if ($ch == " " || $ch == "\r" || $ch == "\n" || $ch == "\t") {
                 continue;
             }
         }
         if ($bInString && $ch == "\\" && !$bSlashed) {
             $bSlashed = true;
             continue;
         }
         if ($ch == "\"" || $ch == "'") {
             if ($bInString) {
                 if (!$bSlashed && $quote_ch == $ch) {
                     $bInString = false;
                     continue;
                 }
             } else {
                 $bInString = true;
                 $quote_ch = $ch;
                 continue;
             }
         }
         $bSlashed = false;
         if ($bInString) {
             $string_tmp .= $ch;
             continue;
         }
         $new_str .= $ch;
     }
     if ($pos = strpos($new_str, "(")) {
         $func_name = substr($new_str, 0, $pos + 1);
         if (preg_match("/^(\\\$[A-Z_][A-Z0-9_]*)(\\s*=\\s*)/i", $func_name, $arMatch)) {
             $var_name = $arMatch[1];
             $func_name = substr($func_name, strlen($arMatch[0]));
         } else {
             $var_name = "";
         }
         self::$arAllStr = $arAllStr;
         $func_name = preg_replace_callback("'([0-9]+)'s", "PHPParser::getString", $func_name);
         switch (strtoupper($func_name)) {
             case '$APPLICATION->INCLUDECOMPONENT(':
                 $params = substr($new_str, $pos + 1);
                 $arParams = PHPParser::GetParams($params);
                 $arIncludeParams = array();
                 $arFuncParams = array();
                 PHPParser::GetParamsRec($arParams[2], $arAllStr, $arIncludeParams);
                 PHPParser::GetParamsRec($arParams[4], $arAllStr, $arFuncParams);
                 return array("COMPONENT_NAME" => PHPParser::ReplString($arParams[0], $arAllStr), "TEMPLATE_NAME" => PHPParser::ReplString($arParams[1], $arAllStr), "PARAMS" => $arIncludeParams, "PARENT_COMP" => $arParams[3], "VARIABLE" => $var_name, "FUNCTION_PARAMS" => $arFuncParams);
         }
     }
     return false;
 }
开发者ID:rasuldev,项目名称:torino,代码行数:88,代码来源:php_parser.php


注:本文中的PHPParser::arAllStr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。