• <bdo id='L9h5o'></bdo><ul id='L9h5o'></ul>
    <legend id='L9h5o'><style id='L9h5o'><dir id='L9h5o'><q id='L9h5o'></q></dir></style></legend>
    <tfoot id='L9h5o'></tfoot>

    <small id='L9h5o'></small><noframes id='L9h5o'>

        <i id='L9h5o'><tr id='L9h5o'><dt id='L9h5o'><q id='L9h5o'><span id='L9h5o'><b id='L9h5o'><form id='L9h5o'><ins id='L9h5o'></ins><ul id='L9h5o'></ul><sub id='L9h5o'></sub></form><legend id='L9h5o'></legend><bdo id='L9h5o'><pre id='L9h5o'><center id='L9h5o'></center></pre></bdo></b><th id='L9h5o'></th></span></q></dt></tr></i><div id='L9h5o'><tfoot id='L9h5o'></tfoot><dl id='L9h5o'><fieldset id='L9h5o'></fieldset></dl></div>

        php中的动态类属性$$value

        时间:2023-08-20
        <i id='fsw0Q'><tr id='fsw0Q'><dt id='fsw0Q'><q id='fsw0Q'><span id='fsw0Q'><b id='fsw0Q'><form id='fsw0Q'><ins id='fsw0Q'></ins><ul id='fsw0Q'></ul><sub id='fsw0Q'></sub></form><legend id='fsw0Q'></legend><bdo id='fsw0Q'><pre id='fsw0Q'><center id='fsw0Q'></center></pre></bdo></b><th id='fsw0Q'></th></span></q></dt></tr></i><div id='fsw0Q'><tfoot id='fsw0Q'></tfoot><dl id='fsw0Q'><fieldset id='fsw0Q'></fieldset></dl></div>

            • <bdo id='fsw0Q'></bdo><ul id='fsw0Q'></ul>
                <tbody id='fsw0Q'></tbody>

              <small id='fsw0Q'></small><noframes id='fsw0Q'>

            • <legend id='fsw0Q'><style id='fsw0Q'><dir id='fsw0Q'><q id='fsw0Q'></q></dir></style></legend>
              <tfoot id='fsw0Q'></tfoot>

                1. 本文介绍了php中的动态类属性$$value的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  如何引用只知道字符串的类属性?

                  How can i reference a class property knowing only a string?

                  class Foo
                  {
                      public $bar;
                  
                      public function TestFoobar()
                      {
                          $this->foobar('bar');
                      }
                  
                      public function foobar($string)
                      {
                           echo $this->$$string; //doesn't work
                      }
                  }
                  

                  评估字符串的正确方法是什么?

                  what is the correct way to eval the string?

                  推荐答案

                  当使用字符串变量引用对象的成员变量时,只需使用一个 $.

                  You only need to use one $ when referencing an object's member variable using a string variable.

                  echo $this->$string;
                  

                  这篇关于php中的动态类属性$$value的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何访问在 php 中命名为变量(点表示法)的深层对象属性? 下一篇:如何避免 PHP 中的动态属性(设置未声明的属性时引发错误)

                  相关文章

                  1. <legend id='sMH8T'><style id='sMH8T'><dir id='sMH8T'><q id='sMH8T'></q></dir></style></legend>
                      <bdo id='sMH8T'></bdo><ul id='sMH8T'></ul>

                    <small id='sMH8T'></small><noframes id='sMH8T'>

                    <tfoot id='sMH8T'></tfoot>

                      <i id='sMH8T'><tr id='sMH8T'><dt id='sMH8T'><q id='sMH8T'><span id='sMH8T'><b id='sMH8T'><form id='sMH8T'><ins id='sMH8T'></ins><ul id='sMH8T'></ul><sub id='sMH8T'></sub></form><legend id='sMH8T'></legend><bdo id='sMH8T'><pre id='sMH8T'><center id='sMH8T'></center></pre></bdo></b><th id='sMH8T'></th></span></q></dt></tr></i><div id='sMH8T'><tfoot id='sMH8T'></tfoot><dl id='sMH8T'><fieldset id='sMH8T'></fieldset></dl></div>