This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
uphp:functions:function_exists [2017/04/06 12:04] jeff removed |
uphp:functions:function_exists [2021/09/13 05:57] (current) |
||
---|---|---|---|
Line 3: | Line 3: | ||
< | < | ||
- | Checks | + | Check if a function |
====Description==== | ====Description==== | ||
- | <well size=" | + | <well size=" |
- | < | + | |
<span style=" | <span style=" | ||
- | <span style=" | + | <span style=" |
- | </ | + | |
- | [[function_exists]] ( | + | |
- | < | + | |
<span style=" | <span style=" | ||
<span style=" | <span style=" | ||
- | <span style=" | + | <span style=" |
- | </ | + | </ |
- | </ | + | |
- | ====Parameters==== | + | 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). |
- | < | + | ====Parameter==== |
- | < | + | < |
- | ====Return | + | ====Return |
- | Any type depending on the way the function | + | < |
- | ====Example==== | + | ====Examples==== |
+ | |||
+ | ===Check for the existence of the ' | ||
<code php> | <code php> | ||
<? | <? | ||
- | | + | $f=" |
- | | + | if (function_exists(" |
+ | | ||
+ | } else { | ||
+ | print(" | ||
} | } | ||
- | $result=call_user_func(" | ||
- | print($result); | ||
?> | ?> | ||
</ | </ | ||
- | ====See Also==== | + | ===Load a list of custom functions and check that a function is included before calling it=== |
- | [[uphp:statements: | + | <code php> |
+ | <? | ||
+ | include("/ | ||
+ | |||
+ | $f=" | ||
+ | if (function_exists($f)) { | ||
+ | print(call_user_func($f, | ||
+ | } else { | ||
+ | print(" | ||
+ | die(); | ||
+ | } | ||
+ | ?> | ||
+ | </ | ||
- | [[uphp: | + | ====See Also==== |
- | ====Additional Information==== | + | [[phpinfo()]] - Return information about the system [including the Firmware Version] |
- | User defined functions can take many different forms, and it is not necessary to use [[call_user_func()]] to execute | + | [[include()]] - Include |
- | If used within | + | [[call_user_func()]] - Call a user defined |
+ | |||
+ | [[uphp: | ||