Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(function_exists('my_function')){
- // my_function is defined
- }
- <?php
- if (!function_exists('myfunction')) {
- function myfunction()
- {
- //write function statements
- }
- }
- ?>
- print_r(get_defined_functions());
- <?php
- // This will print "foo defined"
- if (function_exists('foo')) {
- print "foo defined";
- } else {
- print "foo not defined";
- }
- //note even though the function is defined here, it previously was told to have already existed
- function foo() {}
- <?php
- // This will print "defining bar" and will define the function bar
- if (function_exists('bar')) {
- print "bar defined";
- } else {
- print "defining bar";
- function bar() {}
- }
- $arrFun = array('fun1','fun2','fun3');
- if(is_array($arrFun)){
- $arrMsg = array();
- foreach ($arrFun as $key => $value) {
- if(!function_exists($value)){
- $arrMsg[] = $value;
- }
- }
- foreach ($arrMsg as $key => $value) {
- echo "{$value} function is does not exist <br/>";
- }
- }
- function fun1(){
- }
- Output
- fun2 function is does not exist
- fun3 function is does not exist
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement