Hello @kartik,
Include has the scope of the line it's called from.
If you don't want to create new global variables, you can wrap include()
with a function:
function includeHeader($title) {
include("inc/header.php");
}
$title
will be defined in the included code whenever you call includeHeader
with a value, for example includeHeader('My Fancy Title')
.
If you want to pass more than one variable you can always pass an array instead of a string.