1. Function to print “Hello PHP”
2. Function to add two numbers
3. Function to find square of a number
4. Function with default parameter values
";
greetUser("Boby");
?>
5. Function to calculate factorial
6. Function to return largest of two numbers
$b) ? $a : $b;
}
echo "Largest: " . largest(15, 25);
?>
7. Function to check prime number
8. Function to reverse a string
9. Function to count vowels in a string
10. Function to check palindrome string
11. Demonstrate local and global variables
";
echo "Local y: $y";
}
test();
?>
12. Recursive function for factorial
13. Recursive Fibonacci function
14. Function to calculate area of circle
15. Function to return sum of array elements
16. Function to convert Celsius to Fahrenheit
17. Function to check if number is even
18. Function to capitalize first letter of each word
19. Function to generate multiplication table
";
}
}
table(5);
?>
20. Function to return length of string
21. Function to validate email format
22. Function to generate random password
23. Function to check strong password
24. Function to remove duplicate values from array
25. Function to sort associative array by values
85, "Ravi"=>75, "Sita"=>90];
print_r(sortByValue($students));
?>
26. Function to calculate compound interest
27. Function to sanitize user input
alert('hack')";
echo sanitizeInput($input);
?>
28. Function to check if string contains substring
29. Function to flatten multidimensional array
30. Function to calculate age from DOB
diff($birthDate)->y;
}
echo "Age: " . calculateAge("2000-05-10");
?>
31. Function to generate slug (SEO-friendly URL)
32. Function to paginate array data
33. Function to encrypt password (hashing)
34. Function to verify hashed password
35. Function to find second largest number in array
36. Function to check palindrome number
37. Function to merge and sort arrays
38. Function to count word frequency
39. Function to validate mobile number (India)
40. Function to create JSON response (API-style)
"success", "message"=>"Data fetched"];
echo jsonResponse($data);
?>