This PHP code is an example program that demonstrates how to write simple functions.
<?php // This is a simple function that prints a prayer. // It does not take any arguments or return anything. function PrintSignOfTheCross() { echo "In the name of the Father,<br />"; echo "and of the Son,<br />"; echo "and of the Holy Spirit.<br />"; echo "Amen.<br />"; } // This function takes in a single string value and prints it. function PrintMessage(string $sMessage) { echo $sMessage."<br />"; } // This function returns a value. function GetMessage() { return "Sign of the Cross"; } // This function takes in two string and returns a string. function AssembleMessage(string $sPart1, string $sPart2) { return $sPart1." ".$sPart2; } // Call the first function. echo "<br /><b>First Function</b><hr />"; PrintSignOfTheCross(); // Call the second function. echo "<br /><b>Second Function</b><hr />"; PrintMessage("Our Father"); // Call the third function. echo "<br /><b>Third Function</b><hr />"; echo GetMessage()."<br />"; // Call the fourth function. echo "<br /><b>Fourth Function</b><hr />"; echo AssembleMessage("Jesus", "Christ")."<br />"; ?>
© 20072024 XoaX.net LLC. All rights reserved.