function convert($currencyType)
{
$that = $this;
return $result = function() use ($that)
{
if (!in_array($currencyType, $this->ratio))
return false;
return ($this->ratio[$currencyType] * $this->money); //a float number
};
}
$currency = new Currency();
echo $currency->convert('EURO');
क्या गलत है?क्लास क्लोजर का ऑब्जेक्ट स्ट्रिंग में कनवर्ट नहीं किया जा सका: फ़ाइल नाम।
Catchable fatal error: Object of class Closure could not be converted to string
आपका 'कन्वर्ट()' फ़ंक्शन एक फ़ंक्शन देता है। फिर आप इसे 'echo() 'ing में एक स्ट्रिंग में समन्वयित करने का प्रयास कर रहे हैं। – landons
लेकिन क्लोजर $ परिणाम के लिए एक फ्लोट/झूठा लौटाता है? –
और क्लोजर के अंदर आपके '$ यह' संदर्भ इसके बजाय '$ that' होना चाहिए। वे बदल सकते हैं कि 5.4 विचार में; निश्चित नहीं। – landons