PHP Variable Functions
Variable functions in PHP allow you to call a function using a variable that holds the name of the function. It's useful for dynamic function calls based on logic.
PHP में Variable Functions का मतलब है कि आप एक वेरिएबल के जरिए किसी function को कॉल कर सकते हैं जिसमें उस function का नाम स्टोर हो। यह डायनामिक कॉल्स के लिए उपयोगी होता है।
Basic Variable Function
You can store a function's name in a variable and call it using parentheses.
आप किसी function का नाम एक वेरिएबल में रख सकते हैं और फिर उसे () से कॉल कर सकते हैं।
<?php
function greet() {
echo "Hello from greet!";
}
$func = "greet";
$func();
?>
Hello from greet!
Variable Function with Parameters
You can pass arguments as usual.
आप arguments को सामान्य रूप से पास कर सकते हैं।
<?php
function add($a, $b) {
echo $a + $b;
}
$calc = "add";
$calc(10, 20);
?>
30