Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/277.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在特定页面中显示url中的特定元素?_Php - Fatal编程技术网

Php 如何在特定页面中显示url中的特定元素?

Php 如何在特定页面中显示url中的特定元素?,php,Php,例如,我有以下URL: http://......com/boutique/index.php?Blog&Content&blog_content_id=2 http://......com/boutique/index.php?Products&Specials http://......com/boutique/index.php?Products&Description&products_id=2 http://......com/boutique/

例如,我有以下URL:

http://......com/boutique/index.php?Blog&Content&blog_content_id=2
http://......com/boutique/index.php?Products&Specials
http://......com/boutique/index.php?Products&Description&products_id=2
http://......com/boutique/index.php?Info&Contact
http://......com/boutique/index.php?Info&Contact&Success
http://......com/boutique/index.php?cPath=7_36
http://......com/boutique/index.php
我只想获取一个或多个元素并显示在目录中。 “详细信息”页面是在“管理”中选择的 范例

我试过了,但效果不好。 在我的代码下面

        if ( class_exists($class) ) {
          $mb = new $class();

// Dynamic template
          if(!isset($mb->pages) && ($mb->isEnabled())){
            $this->pages = 'all'; //########## Display in all page the elements
            $mb->execute(); // ##############  work fine
          } else {


    // hide or display the box left / right - explode the element selected
            $page = (explode(';' , $mb->pages));  
    // example of return $page after a var_dump
    // array(2) { [0]=> string(12) "Blog&Content" [1]=> string(0) "" } 
    //array(1) { [0]=> string(3) "all" } array(1) { [0]=> string(3) "all" } 
    //array(1) { [0]=> string(3) "all" } array(1) { [0]=> string(3) "all" } 
    //array(2) { [0]=> string(9) "index.php" [1]=> string(0) "" } 



            if( ($mb->isEnabled() && $mb->pages == 'all') ) {
              $mb->execute(); //############ display all element in all the pages
            } else {
              if( ($mb->isEnabled() && $mb->pages == true) ) {
                $string = $_SERVER['QUERY_STRING']; 

//var_dump(in_array($string , $page));

                if (in_array($string , $page) == true) {
                  if (!empty(in_array('index.php' , $page))) {
                    $mb->execute(); //############ display the element in a specifics pages
                  } else {
                    $mb->notEnabled; //############ not display the page
                  }
                }
              }
           }
        }

看起来您已经在使用某种类型的框架。如果是这种情况,您可能不必直接从
$\u GET[]
中解析内容,您有没有因为我被阻止而提供的示例。嗨,艾米,如果您使用的是一个已知的框架,您能否编辑您的帖子,并向我们提供关于该框架的详细信息?看起来是的,如果是的话,可能有一种很好的、简单的方法来解析查询字符串。否则,我仍然建议像这样使用
$\u GET
        if ( class_exists($class) ) {
          $mb = new $class();

// Dynamic template
          if(!isset($mb->pages) && ($mb->isEnabled())){
            $this->pages = 'all'; //########## Display in all page the elements
            $mb->execute(); // ##############  work fine
          } else {


    // hide or display the box left / right - explode the element selected
            $page = (explode(';' , $mb->pages));  
    // example of return $page after a var_dump
    // array(2) { [0]=> string(12) "Blog&Content" [1]=> string(0) "" } 
    //array(1) { [0]=> string(3) "all" } array(1) { [0]=> string(3) "all" } 
    //array(1) { [0]=> string(3) "all" } array(1) { [0]=> string(3) "all" } 
    //array(2) { [0]=> string(9) "index.php" [1]=> string(0) "" } 



            if( ($mb->isEnabled() && $mb->pages == 'all') ) {
              $mb->execute(); //############ display all element in all the pages
            } else {
              if( ($mb->isEnabled() && $mb->pages == true) ) {
                $string = $_SERVER['QUERY_STRING']; 

//var_dump(in_array($string , $page));

                if (in_array($string , $page) == true) {
                  if (!empty(in_array('index.php' , $page))) {
                    $mb->execute(); //############ display the element in a specifics pages
                  } else {
                    $mb->notEnabled; //############ not display the page
                  }
                }
              }
           }
        }