define() function in PHP


The define() function defines a constant.

Syntax

define(const_name,value,case_insensitive)

Parameters

  • const_name − The name of the constant.

  • value − The value of the constant.

  • case_insensitive − The constant name should be case-insensitive.

Return

The define() function returns true on success or false on failure.

Example

The following is an example that defines a constant.

 Live Demo

<?php
      define("message","This is it!");
   echo constant("message");
?>

Ouptut

The following is the output.

This is it!

Updated on: 27-Jun-2020

566 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements