private function compile($processor, $exec, $ext) { $content = $processor->getContents(); $content = shell_exec_stdio($exec, $content); $relativePath = $processor->getRelativePath(); $relativePath = str_slice($relativePath, 0, -strlen($processor->getType())) . $ext; $processor->setType($ext); $processor->setRelativePath($relativePath); $processor->setContents($content); }
<?php echo $_SERVER['HTTP_USER_AGENT'] . "\n\n"; $ua = $_SERVER['HTTP_USER_AGENT']; $inwx = preg_match('/MicroMessenger/', $ua); echo $inwx; // $browser = get_browser(null, true); // print_r($browser); $queryString = urldecode($_SERVER['QUERY_STRING']); echo $queryString; $arr = str_slice($queryString); // function getQueryObj($queryString){ // $arr = []; // for ($i = 0,$l = $queryString.length; $i < $l; $i++) { // if ($queryString[$i] == '&') // } // } // function getBrowser(){ // //判断是否在微信浏览器中 // return preg_match('/MicroMessenger/', $_SERVER['HTTP_USER_AGENT']); // } // function getSearchString(){ // $queryString = urldecode($_SERVER['QUERY_STRING']); // }
/** * 给字符串去掉一个字符串,并加上一个字符串 * @param $str * @param $remove * @param $add * @return string */ function str_remove_add($str, $remove, $add = '') { if (!empty($remove)) { $len = strlen($remove); if (str_slice($str, 0, $len) === $remove) { $str = str_slice($str, $len); } } if (!empty($add)) { $str = $add . $str; } return $str; }
/** * 加载配置 */ protected final function initConfig() { // 加载配置文件 C($this->options['config']); // 初始化静态文件访问前缀 // 用于引用路径和实际路径的映射 if (isset($this->options['static_case'])) { $staticInSrc = $this->options['static_case']['static_in_src']; $staticInFile = $this->options['static_case']['static_in_file']; $staticInBuild = $this->options['static_case']['static_in_build']; if ($staticInSrc && $staticInFile) { str_diff($staticInSrc, $staticInFile, $pos); $pos = $pos ? -$pos : null; C('STATIC_ACTUAL_PREFIX', str_slice($staticInSrc, 0, $pos)); C('STATIC_VIRTUAL_PREFIX', str_slice($staticInFile, 0, $pos)); } if ($staticInSrc && $staticInBuild) { str_diff($staticInSrc, $staticInBuild, $pos); $pos = $pos ? -$pos : null; C('STATIC_BUILD_PREFIX', str_slice($staticInFile, 0, $pos)); } } // 加载自定义插件 $pluginPath = C('PLUGIN_PATH'); if ($pluginPath && file_exists($pluginPath)) { Plugin::start($pluginPath); } }
public function createPhoneRequest($phone) { $countryCode = '+231'; //need to make config $phones = array(); foreach (explode('/', $phone) as $number) { $number = preg_replace('/[^\\d\\+]/', '', trim($number)); if (!is_string($number) || strlen($number) == 0) { continue; } if ($number[0] == '+') { $phones[] = $number; } else { if ($number[0] != '0') { $phones[] = $countryCode . $number; } else { if ($number[1] == '0') { $phones[] = str_slice($number, 2); } else { $phones[] = $countryCode + str_slice($number, 1); } } } } $xml = "\n <requestParams xmlns:csd='urn:ihe:iti:csd:2013'> \n"; foreach ($phones as $numbers) { $xml .= "\n <csd:contactPoint><csd:codedType>" . $number . "</csd:codedType></csd:contactPoint>"; } $xml .= "\n </requestParams>\n"; return $xml; }