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

WBOY
Release: 2016-07-25 09:04:48
Original
1077 people have browsed it
  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


source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template