$var = funcName ( parameters ); |
Example 1:
<?php $x = sin(1); print $x . "\n"; ?> |
How to run the program:
|
<?php $a = ""; $b = "abc"; if ( empty($a) ) { print("a is empty\n"); } else { print("a is not empty\n"); } if ( empty($b) ) { print("b is empty\n"); } else { print("b is not empty\n"); } ?> |
How to run the program:
|
function funcName ( $param1 , $param2 , .... ) { statements } |
function square( $x ) { $r = $x * $x ; return( $r ); } |
$a = square( 4 ); |
Example:
<?php $a = square(4); print("Square of 4 = " . $a . "\n"); # Function definition function square( $x ) { $r = $x * $x ; return( $r ); } ?> |
How to run the program:
|
|