How can PHP functions be used across multiple pages?
To use PHP functions across multiple pages, you can create a separate PHP file containing the functions you want to reuse and then include this file in your other PHP pages using the include or require statement.
// functions.php
<?php
function greetUser($name) {
echo "Hello, $name!";
}
?>
// index.php
<?php
include 'functions.php';
greetUser('John');
?>
Related questions
-
SQL queries LIKE statement filtering results
-
$_POST form data handling
-
PHP line breaks .db files