define() function in php code example

Example 1: how to define function in php

<?php
function writeMsg() {
    echo "Hello world!";
}

writeMsg(); //call the function
?>

Example 2: define in php

//define() is used to create constants
define(name,value);
//here name has to be a string
//here value can be string, integer, float, boolean or NULL, 
//and can be an array to if you are using PHP 7.0+

//define() before php 7.3
define(name,value,case_insensitive);
//case_insensitive is optional and can be TRUE or FALSE by default its false

Tags:

Php Example