Print String in PHP

Print String in PHP. Using this program we can print the string in the output using defined function. A global variable is a variable that is defined outside of the function. Global variables are accessible from any point in the script, even within and outside of functions. As a result, while a global variable can be declared just like any other variable, it must be declared outside of the function definition.

define("inlarn", "Welcome to");

function sample()
echo inlarn;




Welcome to

Defined Function in PHP

A user-defined function’s declaration begins with the word function, followed by the name of the function you want to write, parenthesis (), and lastly your function’s code enclosed in curly brackets. The defined() function in PHP is a built-in function that tests whether a constant exists or not, in other words, whether it is defined. defined($constant name); bool defined($constant name); Parameter: As noted before and described below, this function only accepts one parameter.

Function in PHP

In PHP, a function is a reusable piece of code that performs a certain operation. When called, functions can either return values or just conduct an action without returning any value. PHP includes around 700 built-in functions that accomplish various tasks. PHP offers us with two kinds of functions: Built-in functions: PHP comes with a plethora of built-in library functions. User-Defined Functions (UDFs): Aside from the built-in functions, PHP allows us to write our own unique functions, known as user-defined functions.