Home >Backend Development >PHP Tutorial >Three small examples of PHP determining whether constants, variables and functions exist

Three small examples of PHP determining whether constants, variables and functions exist

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-25 09:04:481136browse
  1. /* Determine whether the constant exists*/

  2. if (defined('MYCONSTANT')) {
  3. echo MYCONSTANT;
  4. }

  5. //Judge whether the variable exists

  6. if (isset($myvar)) {
  7. echo "The variable $myvar exists.";
  8. }

  9. //Judge whether the function exists

  10. if (function_exists(' imap_open')) {
  11. echo "Function imag_openn exists";
  12. } else {
  13. echo "Function imag_open does not existn";
  14. }
  15. ?>

Copy code


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn