include() allows you to include the code contained in another library or script file inside a php file, just as if the code had been copied and pasted into the php file
animal_functions.php
function animalSpeak( $animal ) {
$sounds = array ( “cat” = > “meow”, “dog” = > “woof”, “mouse” = >“squeak” );
return $sounds[$animal];
}
echo animalSpeak( “mouse” ) . “ < br / > ”; // Displays “squeak”
echo animalSpeak( “cat” ) . “ < br / > ”; // Displays “meow”
mouse.php
<?php
include( “animal_functions.php” );
echo animalSpeak( “mouse” ) . “ < br / > ”; // Displays “squeak”;
?>