2016-12-12 8 views
0

클래스 호출 VSE가 있고 거기에 이상의 함수가 있습니다. 모든 함수에서 는 내가 그 $url 모든 변수를 나열 할 $url다른 클래스의 함수 변수에 액세스

<?php 
namespace App; 
use Request, Cache, App\Helper; 


class VSE { 

    . 
    . 
    public static function wifi_device_state_all($cpe_mac, $wifi_index) { 
     $url = env('API_HOST').'vse/vcpe/'.$cpe_mac.'/wifi_index/'.$wifi_index.'/wifi_device_state.all'; 
     return Helper::getData($url); 
    } 
    . 
    . 

} 

변수 호출을 가지고있다.

I했습니다

$functions = get_class_methods(\App\VSE::class); 
    foreach ($functions as $function) { 
     dd($function); // I got function name printed 
    } 

상자에서 그 권리 같은 것을 제공한다 PHP에서 함수가 있습니까?

아니면 해키를 만들어야합니까?

어떤 힌트가 있습니까?


@Machavity :

당신이 표시 한 이후 내 으로 게시하는 것은 중복. 귀하가 제안한 링크를 시도했습니다 :

액세스하려고 시도한 내 $url 변수가 실제로 표시되지 않았습니다.

여기에 뭔가가 빠졌습니까?

ReflectionClass {#444 ▼ 
    +name: "App\VSE" 
    implements: [] 
    constants: [] 
    methods: array:86 [▼ 
    "account" => ReflectionMethod {#452 ▼ 
     +name: "account" 
     +class: "App\VSE" 
     parameters: array:1 [▼ 
     "$id" => ReflectionParameter {#542 ▼ 
      +name: "id" 
      position: 0 
     } 
     ] 
     modifiers: "public static" 
    } 
    "account_all" => ReflectionMethod {#453 ▼ 
     +name: "account_all" 
     +class: "App\VSE" 
     modifiers: "public static" 
    } 
    "count_accounts" => ReflectionMethod {#454 ▼ 
     +name: "count_accounts" 
     +class: "App\VSE" 
     modifiers: "public static" 
    } 
    "locations" => ReflectionMethod {#455 ▼ 
     +name: "locations" 
     +class: "App\VSE" 
     modifiers: "public static" 
    } 
    "location" => ReflectionMethod {#456 ▼ 
     +name: "location" 
     +class: "App\VSE" 
     parameters: array:1 [▼ 
     "$id" => ReflectionParameter {#547 ▼ 
      +name: "id" 
      position: 0 
     } 
     ] 
     modifiers: "public static" 
    } 
    "follow_me" => ReflectionMethod {#457 ▼ 
     +name: "follow_me" 
     +class: "App\VSE" 
     parameters: array:1 [▼ 
     "$id" => ReflectionParameter {#549 ▼ 
      +name: "id" 
      position: 0 
     } 
     ] 
     modifiers: "public static" 
    } 
    "vcpe" => ReflectionMethod {#458 ▶} 
    "cpe" => ReflectionMethod {#459 ▶} 
    "vcpes_all" => ReflectionMethod {#460 ▶} 
    "vcpes_in_account" => ReflectionMethod {#461 ▶} 
    "cpe_name" => ReflectionMethod {#462 ▶} 
    "ipv6_portforward" => ReflectionMethod {#463 ▶} 
    "ipv6_enable" => ReflectionMethod {#464 ▶} 
    "ipv4_block_fragment_packets" => ReflectionMethod {#465 ▶} 
    "ipv6_block_fragment_packets" => ReflectionMethod {#466 ▶} 
    "ipv6_firewall" => ReflectionMethod {#467 ▶} 
    "acl" => ReflectionMethod {#468 ▶} 
    "tunnel_states" => ReflectionMethod {#469 ▶} 
    "tunnel_state" => ReflectionMethod {#470 ▶} 
    "cgnat" => ReflectionMethod {#471 ▶} 
    "cpe_location" => ReflectionMethod {#472 ▶} 
    "vcpes_account_count" => ReflectionMethod {#473 ▶} 
    "vcpes_count" => ReflectionMethod {#474 ▶} 
    "count_tunnel_states" => ReflectionMethod {#475 ▶} 
    "count_tunnel_state" => ReflectionMethod {#476 ▶} 
    "count_device_states" => ReflectionMethod {#477 ▶} 
    "count_device_state" => ReflectionMethod {#478 ▶} 
    "count_device" => ReflectionMethod {#479 ▶} 
    "private_devices" => ReflectionMethod {#480 ▶} 
    "guest_devices" => ReflectionMethod {#481 ▶} 
    "device_state" => ReflectionMethod {#482 ▶} 
    "private_groups" => ReflectionMethod {#483 ▶} 
    "group_devices" => ReflectionMethod {#484 ▶} 
    "private_bandwidth" => ReflectionMethod {#485 ▶} 
    "this_bandwidth" => ReflectionMethod {#486 ▶} 
    "guest_bandwidth" => ReflectionMethod {#487 ▶} 
    "total_bandwidth" => ReflectionMethod {#488 ▶} 
    "device" => ReflectionMethod {#489 ▶} 
    "device_rate_limit" => ReflectionMethod {#490 ▶} 
    "device_acl_all" => ReflectionMethod {#491 ▶} 
    "device_acl" => ReflectionMethod {#492 ▶} 
    "schedule_use_data" => ReflectionMethod {#493 ▶} 
    "schedule_use" => ReflectionMethod {#494 ▶} 
    "bandwidth" => ReflectionMethod {#495 ▶} 
    "wan" => ReflectionMethod {#496 ▶} 
    "wan_bandwidth" => ReflectionMethod {#497 ▶} 
    "wan_vlan_bandwidth" => ReflectionMethod {#498 ▶} 
    "wan_bandwidth2" => ReflectionMethod {#499 ▶} 
    "portforward" => ReflectionMethod {#500 ▶} 
    "cpe_lan" => ReflectionMethod {#501 ▶} 
    "lan" => ReflectionMethod {#502 ▶} 
    "this_lan_acl" => ReflectionMethod {#503 ▶} 
    "lan_acl" => ReflectionMethod {#504 ▶} 
    "this_lan_acl_device" => ReflectionMethod {#505 ▶} 
    "lan_acl_device" => ReflectionMethod {#506 ▶} 
    "dnsbridge" => ReflectionMethod {#507 ▶} 
    "device_dnsbridge" => ReflectionMethod {#508 ▶} 
    "p_dnsbridge" => ReflectionMethod {#509 ▶} 
    "g_dnsbridge" => ReflectionMethod {#510 ▶} 
    "security_level_vlan" => ReflectionMethod {#511 ▶} 
    "security_level_device" => ReflectionMethod {#512 ▶} 
    "security_level_group" => ReflectionMethod {#513 ▶} 
    "this_acl" => ReflectionMethod {#514 ▶} 
    "guest_acl" => ReflectionMethod {#515 ▶} 
    "this_devicebandwidth" => ReflectionMethod {#516 ▶} 
    "devicebandwidth" => ReflectionMethod {#517 ▶} 
    "this_network_bandwidth" => ReflectionMethod {#518 ▶} 
    "guest_network_bandwidth" => ReflectionMethod {#519 ▶} 
    "this_lan" => ReflectionMethod {#520 ▶} 
    "lan_guest" => ReflectionMethod {#521 ▶} 
    "hour_vlan" => ReflectionMethod {#522 ▶} 
    "week_vlan" => ReflectionMethod {#523 ▶} 
    "month_vlan" => ReflectionMethod {#524 ▶} 
    "device_hour" => ReflectionMethod {#525 ▶} 
    "device_week" => ReflectionMethod {#526 ▶} 
    "device_month" => ReflectionMethod {#527 ▶} 
    "wifi_device_state" => ReflectionMethod {#528 ▶} 
    "wifi_device_passphrase" => ReflectionMethod {#529 ▶} 
    "wifi_device_ssid" => ReflectionMethod {#530 ▶} 
    "wifi_device_list" => ReflectionMethod {#531 ▶} 
    "wifi_device_state_all" => ReflectionMethod {#532 ▶} 
    "cloud_security" => ReflectionMethod {#533 ▶} 
    "mirror_server" => ReflectionMethod {#534 ▶} 
    "facebook" => ReflectionMethod {#535 ▶} 
    "volume_limit" => ReflectionMethod {#536 ▶} 
    "volume_limit_current" => ReflectionMethod {#537 ▶} 
    ] 
    extra: array:4 [▼ 
    "file" => "/Applications/MAMP/htdocs/code/site/portal/app/VSE.php" 
    "line" => "14 to 609" 
    "docComment" => """ 
     /**\n 
     * Test Default Value\n 
     * env('API_HOST') = 172.16.200.204\n 
     * $cpe_mac = 000D6751560C\n 
     * $account_id = 1002\n 
     *\n 
     */ 
     """ 
    "isUserDefined" => true 
    ] 
} 
+1

를 무슨 말인지 모르겠어요 - 그들은 방법 범위 변수에 있기 때문에, 당신은'$ URL의 반환 값을 찾고 있습니다 '수업 중 모든 방법에 대해? –

+0

테스트 환경에서만 검색하려고합니까? – Shane

+0

내가 이것을 골라서 내가 이것을 골라 낼지 확실하지 않았다. 다른 경쟁자는 http://stackoverflow.com/questions/11575724/php-how-to-list-out-all-public-functions-of-class – Machavity

답변

0

클래스 메서드를 동적으로 호출하려는 것처럼 들립니다. 당신은 반사 API를 사용하여도 사용할 수 있습니다, 구문 여기를 참조하십시오

https://stackoverflow.com/a/251512/7281447

+0

입니다. 질문이 이와 같은 복제본 인 경우 폐쇄로 플래그를 지정하십시오. . 중복 질문은 종종 삭제됩니다 – Machavity

+0

, 조언을 주셔서 감사합니다. – baku

+0

@baku : 사실, 당신의 제안은 친절합니다. 그러나, 나는 질문이있다. – ihue

관련 문제