User Tools

Site Tools


uphp:functions:function_exists

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

uphp:functions:function_exists [2017/04/13 07:15]
jeff
uphp:functions:function_exists [2021/09/13 05:57]
Line 1: Line 1:
-======function_exists====== 
- 
-<badge>WMPRO, WMMINI FW >= 1.887</badge> <badge>WMMEGA FW >= 2.0</badge> 
- 
-Check if a function exists (native or custom) 
- 
-====Description==== 
- 
-<well size="sm"> 
-<html> 
-<span style="font-size:125%;color:green">int 
-<span style="color:black"> 
-</html> 
-[[function_exists]] ( 
-<html> 
-<span style="color:green">string 
-<span style="color:blue">$function_name 
-<span style="color:black">) 
-</html> 
-</well> 
- 
-This function will check to see if a function exists in firmware (native, internal) or has been defined in the current script context (custom, user-defined).  It is useful if a script needs to determine if it is being run on an older version of the firmware that might not have some of the newer functions. It can also be used for controlling flow in scripts that define custom functions depending on certain conditions or [[include|included]] files. 
- 
-====Parameter==== 
- 
-<html><b><span style="color:blue">$function_name<span style="color:black"></b>:  <b><span style="color:green">String<span style="color:black"></b> containing the name of the function to check for existence</html> 
- 
-====Return Value==== 
- 
-<html><b><span style="color:green">Integer<span style="color:black"></b></html>:  1 (true) if the function exists, 0 (false) if the function does not exist 
- 
-====Examples==== 
- 
-===Check for the existence of the 'array_key' function (available if firmware >= 1.953)=== 
- 
-<code php> 
-<? 
-  $f="array_key" 
-  if (function_exists("array_key")) { 
-    print("The function 'array_key' is available"); 
-  } else { 
-    print("The function 'array_key' is NOT available"); 
-  } 
-?> 
-</code> 
- 
-===Load a list of custom functions and check that a function is included before calling it=== 
- 
-<code php> 
-<? 
-  include("/my_functions.inc"); 
-   
-  $f="my_function_number_23"; 
-  if (function_exists($f)) { 
-    print(call_user_func($f,1,3)); 
-  } else { 
-    print("Error: '/my_functions.inc' does not include function '".$f."'"); 
-    die(); 
-  } 
-?> 
-</code> 
- 
-====See Also==== 
- 
-[[phpinfo()]] - Return information about the system [including the Firmware Version] 
- 
-[[include()]] - Include a file within the current script at the current location 
- 
-[[call_user_func()]] - Call a user defined function with optional parameters 
- 
-[[uphp:statements:function]] - Define a function 
  
uphp/functions/function_exists.txt · Last modified: 2021/09/13 05:57 (external edit)