久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <tfoot id='qd4Ro'></tfoot>
    1. <legend id='qd4Ro'><style id='qd4Ro'><dir id='qd4Ro'><q id='qd4Ro'></q></dir></style></legend>
      1. <small id='qd4Ro'></small><noframes id='qd4Ro'>

      2. <i id='qd4Ro'><tr id='qd4Ro'><dt id='qd4Ro'><q id='qd4Ro'><span id='qd4Ro'><b id='qd4Ro'><form id='qd4Ro'><ins id='qd4Ro'></ins><ul id='qd4Ro'></ul><sub id='qd4Ro'></sub></form><legend id='qd4Ro'></legend><bdo id='qd4Ro'><pre id='qd4Ro'><center id='qd4Ro'></center></pre></bdo></b><th id='qd4Ro'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='qd4Ro'><tfoot id='qd4Ro'></tfoot><dl id='qd4Ro'><fieldset id='qd4Ro'></fieldset></dl></div>
          <bdo id='qd4Ro'></bdo><ul id='qd4Ro'></ul>

        PHP 反射 - 獲取方法參數類型為字符串

        PHP Reflection - Get Method Parameter Type As String(PHP 反射 - 獲取方法參數類型為字符串)
          <tbody id='5W9Bx'></tbody>
      3. <small id='5W9Bx'></small><noframes id='5W9Bx'>

        <legend id='5W9Bx'><style id='5W9Bx'><dir id='5W9Bx'><q id='5W9Bx'></q></dir></style></legend>

        • <tfoot id='5W9Bx'></tfoot>

            <bdo id='5W9Bx'></bdo><ul id='5W9Bx'></ul>

                <i id='5W9Bx'><tr id='5W9Bx'><dt id='5W9Bx'><q id='5W9Bx'><span id='5W9Bx'><b id='5W9Bx'><form id='5W9Bx'><ins id='5W9Bx'></ins><ul id='5W9Bx'></ul><sub id='5W9Bx'></sub></form><legend id='5W9Bx'></legend><bdo id='5W9Bx'><pre id='5W9Bx'><center id='5W9Bx'></center></pre></bdo></b><th id='5W9Bx'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='5W9Bx'><tfoot id='5W9Bx'></tfoot><dl id='5W9Bx'><fieldset id='5W9Bx'></fieldset></dl></div>
                1. 本文介紹了PHP 反射 - 獲取方法參數類型為字符串的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在嘗試使用 PHP 反射根據控制器方法中的參數類型自動動態加載模型的類文件.這是一個示例控制器方法.

                  I'm trying to use PHP reflection to dynamically load the class files of models automatically based upon the type of parameter that is in the controller method. Here's an example controller method.

                  <?php
                  
                  class ExampleController
                  {
                      public function PostMaterial(SteelSlugModel $model)
                      {
                          //etc...
                      }
                  }
                  

                  這是我目前所擁有的.

                  //Target the first parameter, as an example
                  $param = new ReflectionParameter(array('ExampleController', 'PostMaterial'), 0);
                  
                  //Echo the type of the parameter
                  echo $param->getClass()->name;
                  

                  這有效,并且輸出將是SteelSlugModel",正如預期的那樣.但是,模型的類文件可能尚未加載,并且使用 getClass() 需要定義類 - 我這樣做的部分原因是自動加載控制器操作可能需要的任何模型.

                  This works, and the output would be 'SteelSlugModel', as expected. However, there is the possibility that the class file of the model may not be loaded yet, and using getClass() requires that the class be defined - part of why I'm doing this is to autoload any models that a controller action may require.

                  有沒有辦法不用先加載class文件就可以得到參數類型的名字?

                  Is there a way to get the name of the parameter type without having to load the class file first?

                  推薦答案

                  我認為唯一的方法是export 并操作結果字符串:

                  I think the only way is to export and manipulate the result string:

                  $refParam = new ReflectionParameter(array('Foo', 'Bar'), 0);
                  
                  $export = ReflectionParameter::export(
                     array(
                        $refParam->getDeclaringClass()->name, 
                        $refParam->getDeclaringFunction()->name
                     ), 
                     $refParam->name, 
                     true
                  );
                  
                  $type = preg_replace('/.*?(w+)s+$'.$refParam->name.'.*/', '\1', $export);
                  echo $type;
                  

                  這篇關于PHP 反射 - 獲取方法參數類型為字符串的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  MySQLi prepared statement amp; foreach loop(MySQLi準備好的語句amp;foreach 循環)
                  Is mysqli_insert_id() gets record from whole server or from same user?(mysqli_insert_id() 是從整個服務器還是從同一用戶獲取記錄?)
                  PHP MySQLi doesn#39;t recognize login info(PHP MySQLi 無法識別登錄信息)
                  mysqli_select_db() expects exactly 2 parameters(mysqli_select_db() 需要 2 個參數)
                  Php mysql pdo query: fill up variable with query result(Php mysql pdo 查詢:用查詢結果填充變量)
                  MySQLI 28000/1045 Access denied for user #39;root#39;@#39;localhost#39;(MySQLI 28000/1045 用戶“root@“localhost的訪問被拒絕)

                      <tbody id='g9Ibu'></tbody>

                  • <i id='g9Ibu'><tr id='g9Ibu'><dt id='g9Ibu'><q id='g9Ibu'><span id='g9Ibu'><b id='g9Ibu'><form id='g9Ibu'><ins id='g9Ibu'></ins><ul id='g9Ibu'></ul><sub id='g9Ibu'></sub></form><legend id='g9Ibu'></legend><bdo id='g9Ibu'><pre id='g9Ibu'><center id='g9Ibu'></center></pre></bdo></b><th id='g9Ibu'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='g9Ibu'><tfoot id='g9Ibu'></tfoot><dl id='g9Ibu'><fieldset id='g9Ibu'></fieldset></dl></div>
                    <legend id='g9Ibu'><style id='g9Ibu'><dir id='g9Ibu'><q id='g9Ibu'></q></dir></style></legend><tfoot id='g9Ibu'></tfoot>

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

                        • <bdo id='g9Ibu'></bdo><ul id='g9Ibu'></ul>

                          1. 主站蜘蛛池模板: 免费高清成人 | 午夜久久av | www.jizzjizz| 午夜久久久久久久久久一区二区 | 欧美精品一区二区三区在线 | 欧美日韩久久精品 | 国产ts人妖另类 | 中文字幕av高清 | 欧美高清视频一区 | 日韩第一区 | 亚洲免费观看 | 久在线视频| 欧美视频二区 | 日韩一级精品视频在线观看 | 亚洲欧美日韩网站 | 国产精品久久久久久久久久 | 亚洲一区在线日韩在线深爱 | 国产精品久久久久久 | 酒色成人网 | 久久中文字幕一区 | 久久久久久久久久久蜜桃 | 麻豆成人在线视频 | 午夜在线精品 | 日韩精品久久久久久 | 91免费在线播放 | 亚洲乱码一区二区三区在线观看 | 日韩欧美在线精品 | 久久久久精| 国产精品亚洲精品 | 亚洲综合大片69999 | 国产日韩欧美激情 | 国产日韩欧美综合 | av片网站 | 欧美一区二区在线播放 | 国产精品免费一区二区三区四区 | 久久国产精品-国产精品 | 久久乐国产精品 | 91久久久久久久久久久久久 | 精品一区二区电影 | 日韩一区二区三区av | 中文字幕乱码一区二区三区 |