本文整理汇总了PHP中mb_parse_str函数的典型用法代码示例。如果您正苦于以下问题:PHP mb_parse_str函数的具体用法?PHP mb_parse_str怎么用?PHP mb_parse_str使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mb_parse_str函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPutParameters
private static function getPutParameters($input)
{
$putdata = $input;
if (function_exists('mb_parse_str')) {
mb_parse_str($putdata, $outputdata);
} else {
parse_str($putdata, $outputdata);
}
return $outputdata;
}
示例2: getInputData
public static function getInputData()
{
if (self::$inputData === null) {
$inputData = [];
$rawInput = file_get_contents('php://input');
if (!empty($rawInput)) {
mb_parse_str($rawInput, $inputData);
}
self::$inputData = $inputData;
}
return self::$inputData;
}
示例3: f_contents
function f_contents(&$text){
$phrase = 'СТРАНИЦА';
if (mb_strpos($text, $phrase) === false) { return true; }
$regex = '/{('. $phrase .'=)\s*(.*?)}/ui';
$matches = array();
preg_match_all($regex, $text, $matches, PREG_SET_ORDER);
$GLOBALS['pt'] = array();
foreach ($matches as $elm) {
$elm[0] = str_replace('{', '', $elm[0]);
$elm[0] = str_replace('}', '', $elm[0]);
mb_parse_str($elm[0], $args);
$title = @$args[$phrase];
if ($title) {
$GLOBALS['pt'][] = $title;
}
$text = str_replace('{'.$phrase.'='.$title.'}', '', $text );
}
return true;
}
示例4: getParsedBody
/**
* Retorna o conteudo do request parseado para GET, POST, PUT e DELETE
* ou lança uma exceção caso o tipo de content-type seja inválido
* @return array
*/
public function getParsedBody()
{
if (!in_array($this->getMethod(), ['GET', 'POST'])) {
if ($this->getContentType() == 'application/x-www-form-urlencoded') {
$input_contents = file_get_contents("php://input");
if (function_exists('mb_parse_str')) {
mb_parse_str($input_contents, $post_vars);
} else {
parse_str($input_contents, $post_vars);
}
if (count($_GET) > 0) {
$post_vars = array_merge($post_vars, $_GET);
}
return $post_vars;
} else {
throw new \UnexpectedValueException('Content-type não aceito');
}
} elseif ($this->getMethod() == 'POST') {
if (count($_GET) > 0) {
$_POST = array_merge($_POST, $_GET);
}
return $_POST;
} elseif ($this->getMethod() == 'GET') {
return $_GET;
}
}
示例5: f_includes
function f_includes(&$text){
$phrase = 'ФАЙЛ';
if (mb_strpos($text, $phrase) === false){
return true;
}
$regex = '/{('.$phrase.'=)\s*(.*?)}/i';
$matches = array();
preg_match_all( $regex, $text, $matches, PREG_SET_ORDER );
foreach ($matches as $elm) {
$elm[0] = str_replace('{', '', $elm[0]);
$elm[0] = str_replace('}', '', $elm[0]);
mb_parse_str( $elm[0], $args );
$file=@$args[$phrase];
if ($file){
$output = getLink($file);
} else { $output = ''; }
$text = str_replace('{'.$phrase.'='.$file.'}', $output, $text );
}
return true;
}
示例6: f_banners
function f_banners(&$text)
{
$phrase = 'БАННЕР';
if (mb_strpos($text, $phrase) === false) {
return true;
}
if (!cmsCore::getInstance()->isComponentEnable('banners')) {
return true;
}
$regex = '/{(' . $phrase . '=)\\s*(.*?)}/i';
$matches = array();
preg_match_all($regex, $text, $matches, PREG_SET_ORDER);
if (!$matches) {
return true;
}
cmsCore::loadModel('banners');
foreach ($matches as $elm) {
$elm[0] = str_replace('{', '', $elm[0]);
$elm[0] = str_replace('}', '', $elm[0]);
mb_parse_str($elm[0], $args);
$position = @$args[$phrase];
if ($position) {
$output = cms_model_banners::getBannerHTML($position);
} else {
$output = '';
}
$text = str_replace('{' . $phrase . '=' . $position . '}', $output, $text);
}
return true;
}
示例7: elgg_parse_str
/**
* Parses a string using mb_parse_str() if available.
* NOTE: This differs from parse_str() by returning the results
* instead of placing them in the local scope!
*
* @param str $str
* @return array
*/
function elgg_parse_str($str)
{
if (is_callable('mb_parse_str')) {
mb_parse_str($str, $results);
} else {
parse_str($str, $results);
}
return $results;
}
开发者ID:ashwiniravi,项目名称:Elgg-Social-Network-Single-Sign-on-and-Web-Statistics,代码行数:17,代码来源:mb_wrapper.php
示例8: queryString
public static function queryString()
{
$queryString = array();
if (function_exists('mb_parse_str')) {
mb_parse_str($_SERVER['QUERY_STRING'], $queryString);
} else {
parse_str($_SERVER['QUERY_STRING'], $queryString);
}
return $queryString;
}
示例9: parseLinkUrl
protected function parseLinkUrl($url)
{
try {
$urlParams = mb_substr($url, mb_strpos($url, '?') + 1);
$array = [];
mb_parse_str(htmlspecialchars_decode($urlParams), $array);
if (!filter_var($array['q'], FILTER_VALIDATE_URL)) {
throw new GoogleParserException($array['q'] . ' invalid url');
}
return $array['q'];
} catch (GoogleParserException $e) {
throw $e;
}
}
示例10: getRestParams
/**
* Returns rest request parameters.
* @return array the request parameters
*/
public function getRestParams()
{
$result = [];
$httpMethod = array('get', 'put', 'delete', 'put', 'patch', 'options');
if (!isset($_SERVER['REQUEST_METHOD']) || !in_array(strtolower($_SERVER['REQUEST_METHOD']), $httpMethod)) {
return $result;
}
if (function_exists('mb_parse_str')) {
mb_parse_str(file_get_contents('php://input'), $result);
} else {
parse_str(file_get_contents('php://input'), $result);
}
return $result;
}
示例11: getInputParams
/**
* Function fetch params from php://input.
* @return array HTTP params
*/
public function getInputParams()
{
$result = array();
$rawBody = Yii::app()->request->rawBody;
if (is_null($result = json_decode($rawBody, true))) {
if (function_exists('mb_parse_str')) {
mb_parse_str(Yii::app()->request->rawBody, $result);
} else {
parse_str(Yii::app()->request->rawBody, $result);
}
}
if (!is_array($result) || empty($result) && !empty($_POST)) {
$result = $_POST;
}
return $result;
}
示例12: getInput
public function getInput(string $method) : array
{
if ($method == 'GET') {
return array('data' => json_decode($_GET, true));
} else {
if ($method == 'POST') {
return array('data' => json_decode($_POST, true));
} else {
if ($method == 'PUT') {
mb_parse_str(file_get_contents("php://input"), $result);
return array('data' => json_decode($result, true));
} else {
throw new \Hx\Http\HttpException("UrlEncoded input decoder not support request method <{$method}>");
}
}
}
}
示例13: replace_text
function replace_text($text, $phrase)
{
$regex = '/{(' . $phrase['title'] . '=)\\s*(.*?)}/ui';
$matches = array();
preg_match_all($regex, $text, $matches, PREG_SET_ORDER);
foreach ($matches as $elm) {
$elm[0] = str_replace(array('{', '}'), '', $elm[0]);
mb_parse_str($elm[0], $args);
$arg = @$args[$phrase['title']];
if ($arg) {
$output = call_user_func($phrase['function'], $arg);
} else {
$output = '';
}
$text = str_replace('{' . $phrase['title'] . '=' . $arg . '}', $output, $text);
}
return $text;
}
示例14: createUrl
/**
* Генерирует URL согласно настройкам или локальному режиму
*
* @param string $queryString
* @param bool|array $mode
*
* @return string
*/
public function createUrl($queryString, $mode = false)
{
if (substr($queryString, 0, 4) === 'http') {
return $queryString;
}
$queryString = trim($queryString, '/');
if (is_array($mode) && !empty($this->config['url_manager'])) {
$config = array_merge($this->config['url_manager'], $mode);
} elseif (!is_array($mode) && !empty($this->config['url_manager'])) {
$config = $this->config['url_manager'];
}
$protocol = !empty($config['https']) ? 'https://' : 'http://';
$hostName = $this->request->getHostName();
$scriptName = null;
if (!empty($config['show_script'])) {
$query = trim($_SERVER['PHP_SELF'], '/');
$scriptName = '/' . explode('/', $query)[0];
}
if (true === $mode) {
$basePath = $protocol . $hostName . $scriptName;
} elseif (false === $mode) {
$basePath = $scriptName;
} else {
$basePath = isset($config['absolute']) && true === $config['absolute'] ? $protocol . $hostName . $scriptName : $scriptName;
}
if (isset($config['pretty']) && false === $config['pretty']) {
if ($queryString[0] === '?') {
return $basePath . '?' . ltrim($queryString, '?');
} else {
$param = $this->parser->parseRoutes($queryString);
return $basePath . '?' . http_build_query($param);
}
} else {
if ($queryString[0] !== '?') {
return $basePath . '/' . $queryString;
} else {
mb_parse_str($queryString, $param);
$param = $this->router->hashFromParam($param);
$queryString = implode('/', $param);
return $basePath . '/' . $queryString;
}
}
}
示例15: f_filelink
function f_filelink(&$text)
{
$phrase = 'СКАЧАТЬ';
//echo "<pre>"; var_dump($text);
if (mb_strpos($text, $phrase) === false) {
return true;
}
//$regex = '/{('.$phrase.'=)\s*(.*?)---(.*?)}/i';
$regex = '/{(' . $phrase . '=\\s*.*?)---(.*?)}/i';
//$regex = '/{('.$phrase.'=)\s*(.*?)}/i';
$matches = array();
preg_match_all($regex, $text, $matches, PREG_SET_ORDER);
foreach ($matches as $elm) {
//echo "<pre>"; var_dump($matches);
/* $elm[0] = str_replace('{', '', $elm[0]);
$elm[0] = str_replace('}', '', $elm[0]); */
//mb_parse_str( $elm[0], $args );
mb_parse_str($elm[1], $args);
$file = @$args[$phrase];
if ($file) {
// echo "<pre>"; var_dump($file);
$output = getDownLoadLink($file, $elm[2]);
} else {
$output = '';
}
$text = str_replace('{' . $phrase . '=' . $file . '---' . $elm[2] . '}', $output, $text);
/*echo "<pre>"; var_dump($elm[2]);
if($elm[2]){
$text = str_replace('{'.$phrase.'='.$file.'---'.$elm[2].'}', $output, $text );
}
else{
$text = str_replace('{'.$phrase.'='.$file.'}', $output, $text );
}*/
}
return true;
}