PHP Functions

title: Functions

PHP Functions Introduction

A function is a block of statements that can be used repeatedly in a program.

Simple Function + Call

function say_hello() { return "Hello!"; } echo say_hello();

Simple Function + Parameter + Call

function say_hello($friend) { return "Hello " . $friend . "!"; } echo say_hello('Tommy');

strtoupper – Makes all Chars BIGGER AND BIGGER!

function makeItBIG($a_lot_of_names) { foreach($a_lot_of_names as $the_simpsons) { $BIG[] = strtoupper($the_simpsons); } return $BIG; } $a_lot_of_names = ['Homer', 'Marge', 'Bart', 'Maggy', 'Lisa']; var_dump(makeItBIG($a_lot_of_names));

strtolower Function

The strtolower() function converts a string to lowercase.

<?php echo strtolower("Hello WORLD."); //hello world. ?>

More Information:

This article needs improvement. You can help improve this article. You can also write similar articles and help the community.