scottnsd
3/16/2019 - 6:42 PM

Saved from https://wpshout.com/learning-php-for-wordpress-development-introduction-to-php-functions/

<?php

// Defining the say_something() function with a single argument
function say_something( $phrase = 'Hello world!' ) {
	// This time what we'll be echoing is a variable!
	echo $phrase; // The value that $phrase takes is controlled by our single passed-in argument.
}

// Calling the say_something() function without passing in an argument
say_something(); // This will output the default value of $phrase, which is "Hello world!"

// Calling the say_something() function with a passed-in argument
say_something( 'Hello PHP lovers!' ); // This will output "Hello PHP lovers!"

say_something( 'Totally other statement!' ); // This will output "Totally other statement!"

?>