62-6 Industrial Communication Systems
Example:
<?php
for ($i=1; $i<=5; $i++) {
echo $i;
}
?>
Output: 1 2 3 4 5
62.3.4 Functions
Functions contain scripts that are called to execute whenever a page loads or is called from anywhere within
a page. ere are around 700 built-in functions available in PHP such as date function, string function, cal-
endar function, array functions, etc. You can create your own function to achieve a specic goal.
Syntax:
function functionName(){
code to be executed;
}
Example
1: Wit
hout
pa
rameters
<?php
function demo() {
//user defined function
$string1="Function string";
echo "function code is executed and displayed";
}
demo();
//calling a function, by using function name
?>
Output: function code is executed and displayed ...