Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/240.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-此语法的含义是什么?_Php_Syntax - Fatal编程技术网

PHP-此语法的含义是什么?

PHP-此语法的含义是什么?,php,syntax,Php,Syntax,我试图理解这行代码,但失败了 $this->request->{self::FLAG\u SHOW\u CONFIG}=='true' 我没有关键字来搜索这种语法 这意味着什么 为什么他们用“==”而不是“==” 为什么他们可以做$this->request->{self::FLAG\u SHOW\u CONFIG},而FLAG\u SHOW\u CONFIG是$this的一个字段,它不属于$this->request 完整的代码是 <?php class Magentotutor

我试图理解这行代码,但失败了

$this->request->{self::FLAG\u SHOW\u CONFIG}=='true'

我没有关键字来搜索这种语法

这意味着什么

  • 为什么他们用“==”而不是“==”

  • 为什么他们可以做$this->request->{self::FLAG\u SHOW\u CONFIG},而FLAG\u SHOW\u CONFIG是$this的一个字段,它不属于$this->request

  • 完整的代码是

    <?php
        class Magentotutorial_Configviewer_Model_Observer {
            const FLAG_SHOW_CONFIG = 'showConfig';
            const FLAG_SHOW_CONFIG_FORMAT = 'showConfigFormat';     
    
            private $request;
    
            public function checkForConfigRequest($observer) {          
                $this->request = $observer->getEvent()->getData('front')->getRequest();
                if($this->request->{self::FLAG_SHOW_CONFIG} === 'true'){
                    $this->setHeader();
                    $this->outputConfig();
                }
            }
    ?>
    

    $this->request->{self::FLAG\u SHOW\u CONFIG}
    与以下内容相同:

    $this->request->showConfig
    

    $this->request->{self::FLAG\u SHOW\u CONFIG}
    与以下内容相同:

    $this->request->showConfig
    

    PHP将
    $this->request->{self::FLAG\u SHOW\u CONFIG}
    解释为
    $this->request->showConfig
    。而
    ==
    基本上是检查值和类型是否相等。检查本页以查看三等号的说明


    此外,请查看此页面以了解PHP中的变量。

    PHP将
    $this->request->{self::FLAG\u SHOW\u CONFIG}
    解释为
    $this->request->showConfig
    。而
    ==
    基本上是检查值和类型是否相等。检查本页以查看三等号的说明

    另外,请查看此页面以了解PHP中的变量。

    非常感谢:)我几乎为这种语法疯狂非常感谢:)我几乎为这种语法疯狂