php - Getting number of parameters for a class method -


मुझे पता है:

  फ़ंक्शन पैरामीटर ($ fn) {$ R = नया प्रतिबिंबण $ fn); रिटर्न $ R- & gt; getNumberOfParameters (); }   

समारोह स्वीकार कर सकते हैं पैरामीटर की संख्या देता है, लेकिन मैं यह कैसे एक वर्ग में मौजूद एक विधि के लिए कर सकता हूँ?

उदाहरण के लिए आप अपने फ़ंक्शन में एक नया पैरामीटर $ क्लैज जोड़ सकते हैं, ताकि आपको तर्क की संख्या को पता चलाना चाहिए। ReflectionFunction का उपयोग करने के बजाय ReflectionClass के साथ ReflectionClass का उपयोग करें।

  फ़ंक्शन पैरामीटर ($ clazz, $ method) {$ C = नया ReflectionClass ($ clazz); $ M = $ C- & gt; getMethod ($ विधि); वापसी $ M- & gt; मिलन संख्याओफ़ पैरामीटर (); }    

Comments

Popular posts from this blog

c# - The item with identity 'Id' already exists in the metadata collection. Parameter name: item -

jquery - How to make a wrapper function in javascript? -

jsp - No mapping found for HTTP request with URI with annotation config Spring MVC and Jetty -