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

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -