Advertisement
Guest User

Untitled

a guest
Jul 29th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. if(function_exists('my_function')){
  2. // my_function is defined
  3. }
  4.  
  5. <?php
  6. if (!function_exists('myfunction')) {
  7.  
  8. function myfunction()
  9. {
  10. //write function statements
  11. }
  12.  
  13. }
  14. ?>
  15.  
  16. print_r(get_defined_functions());
  17.  
  18. <?php
  19. // This will print "foo defined"
  20. if (function_exists('foo')) {
  21. print "foo defined";
  22. } else {
  23. print "foo not defined";
  24. }
  25. //note even though the function is defined here, it previously was told to have already existed
  26. function foo() {}
  27.  
  28. <?php
  29. // This will print "defining bar" and will define the function bar
  30. if (function_exists('bar')) {
  31. print "bar defined";
  32. } else {
  33. print "defining bar";
  34. function bar() {}
  35. }
  36.  
  37. $arrFun = array('fun1','fun2','fun3');
  38. if(is_array($arrFun)){
  39. $arrMsg = array();
  40. foreach ($arrFun as $key => $value) {
  41. if(!function_exists($value)){
  42. $arrMsg[] = $value;
  43. }
  44. }
  45. foreach ($arrMsg as $key => $value) {
  46. echo "{$value} function is does not exist <br/>";
  47. }
  48. }
  49. function fun1(){
  50. }
  51.  
  52. Output
  53.  
  54. fun2 function is does not exist
  55. fun3 function is does not exist
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement