Page 254 - Computer Software Application TP - Volume 1
P. 254
COMPUTER SOFTWARE APPLICATION - CITS
TASK 5: Testing for function existence
If you ever want to know whether you have a function available to you, use the function_exists() function.
This takes one string parameter that is the name of a function and returns true if the function exists or false if
it does not.
1 Open the text editor
2 Write the following codes
<html>
<head> <title>PHP </title></head>
<body>
<?php
function WelcomeMsg()
{
echo “Welcome to GeeksforGeeks”;
}
if (function_exists(‘WelcomeMsg’))
{
echo “WelcomeMsg() function is available.\n”;
}
else
{
echo “WelcomeMsg() function is not available.\n”;
}
?>
<p>END</p>
</body>
</html>
3 Save the program in C:\Apache24\htdocs in a folder with .php extension
4 Run the Apache services from windows services
5 Open the browser and type the following address
http://localhost/foldername/
6 Click the php file to run and verify the output
239
CITS : IT & ITES - Computer Software Application - Exercise 52