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# - LINQ to Entities does not recognize the method 'Int32 IndexOf(System.String, System.StringComparison)' method -

python - Writing Greek in matplotlib labels, titles -

Pygame memory leak with transform.flip -