PHP Misc function
1- define()

Defines a constant value. you can use this constant value to any of the webpage.

Note :- For use constant value. First include page where you define your constant

Return Type :- bool

<?php
define(\"CONSTANT\", \"Hello world.\");
echo CONSTANT.\"<br>\";
echo Constant.\"<br>\";
define(\"GREETING\", \"Hello you.\", true);
echo GREETING.\"<br>\";
echo Greeting.\"<br>\";
?>

output:-
Hello world.
Constant
Hello you.
Hello you.

2- defined()

This function checks your constant is exists or not.

Return Type :- bool

<?php
if (defined(\'CONSTANT\'))
{
echo CONSTANT;
}
?>

output
Hello world.

3- die()


die() funtion stop the execution of the current script and print message also.

Note :- This function is construct by language. This function is equivalent to exit().

<?php
$con=mysql_connect(\'localhost\',\'root\',\'1234\');
if(!$con)
die(\'Mysql not connected\');
?>

output
Mysql not connected

Some Other usefull Misc function(Brief discussion)

exit() :- Working same as die function. This is not real function. This is constuct by language. Return type (int)

eval() :- evaluates the string.

Return type (mixed)

constant() :- Return the value of the constant. Return type (mixed)


Previous
Next