⊗ppPmFSRq 354 of 447 menu

Including Files in PHP

Let's say we have a file that stores a set of functions:

<?php function square($num) { return $num ** 2; } function cube($num) { return $num ** 3; } ?>

Let's make the functions from this file available in our main file. To do this, include the file with functions using the require operator:

<?php require 'functions.php'; ?>

After this, in our main file we can use the functions from the included file:

<?php require 'functions.php'; echo square(3) + cube(4); ?>

Create a file with a useful set of functions. Include it into your main file.

byenru