Hi there,
I am programming in an old fashion - still using functions and not classes. For example, something basic I do when creating a basic template for a site is put the header and footer in a function like so in a file called functions.php
<?php
//header
function outline_start() {
echo '
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>my site</title>
</head>
<body>
';
}
//footer
function outline_end() {
echo '
</body></html>
';
}
?>
Then in another file, like index.php I'd do the following:
<?php
include(functions.php);
outline_start();
echo 'hello world';
outline_end();
?>
This can pose issues security wise with needing to use global variables I've been told and generally is bad practice - right?
What is the best practice?