defined() function in PHP

PHPProgrammingServer Side Programming

The defined() function in PHP checks that constant exists or not.

Syntax

defined(name)

Parameters

  • name− The name of constant.

Return

The defined() function returns true if the constant exists otherwise false.

Example

The following is an example that checks whether a constant exist.

 Live Demo

<?php
   define("myConstant","This is it!");
   echo defined("myConstant");
?>

Output

The following is the output.

1
raja
Updated on 27-Jun-2020 08:57:51

Advertisements