PHP:
In php, you can assign a function name as a string to a variable and call the function by adding “()” after the variable name and appending a semicolon. Like this:
1 2 3 |
function masnun($str) { echo "$str \n"; } $str = "masnun"; $str("hello php!"); |
Python:
In python we call the function using the str as a key to the dictionary recieved by calling the globals() function. Like this:
1 2 3 4 5 |
def masnun(str): print str str = "masnun" globals()[str]("hello python!") |
Cool, eh?