如何在URL中使用此元素

时间:2015-07-22 21:25:57

标签: php url

我需要在这个url boutique / index.php?产品和特色产品,例如Products& Featured

这段代码很重要

// $mb->pages has Products&Featured

(in_array($PHP_SELF , explode(';' , $mb->pages)

但$ PHP_SELF发送index.php,我需要index.php

之后的元素

一个想法?

如果我现在有这个:

感谢。

        if ( class_exists($class) ) {
                    $mb = new $class();
// dynamic template
                    if(!isset($mb->pages) && ($mb->isEnabled())){
                      $this->pages = 'all';
                      $mb->execute();
                    } else {
                      if(($mb->isEnabled()) && (($mb->pages === 'all') || (in_array($PHP_SELF , explode(';' , $mb->pages))))) {
                        $mb->execute();
                      }
                    }
// eof Dynamic Template
                  } 

建议后的解决方案

          if (!empty($_SERVER['QUERY_STRING']) ) {
             if (!empty($_SERVER['QUERY_STRING']) ) {
                if(($mb->isEnabled()) && (isset($mb->pages) === 'all') || ( (in_array($_SERVER['QUERY_STRING'] , explode(';' , $mb->pages) ) ) ))   {
                  $mb->execute();
                }
              } else  {
                //var_dump($PHP_SELF , explode(';' , $mb->pages));

                if(($mb->isEnabled()) && (isset($mb->pages) === 'all') || ( (in_array($PHP_SELF , explode(';' , $mb->pages) ) ) ))   {
                  $mb->execute();
                }
          }

2 个答案:

答案 0 :(得分:0)

[{1}}

的['查询']部分
parse_url

答案 1 :(得分:0)

$url = 'boutique/index.php?Products&Featured';
$urlArray = parse_url($url);

echo $urlArray['query'];