Thanks to the help here I got this code working:
<?php
require_once('includes/test.inc');
//set page specific variables
$pgtitle = "OMGMA Test Page";
$css = "../main.css";
do_html_header($pgtitle,$css);
?>
</head>
<body>
The do_html_header() function from the test.inc files is as follows:
<?php
function do_html_header($title, $style)
{
// print an HTML header
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<title><?php echo $title; ?></title>
<link rel="stylesheet" type="text/css" href="<?php echo $style; ?>">
<?php
}
?>
So what I am wanting to do now is to be able to pass more than one CSS file link to the function.
What would be the preferred method to do this? Do I need an array?
To be a little more specific I want to be able to put in my page, variables for more than one css file. I could see using up to 4 links, although sometimes I might only have one or two files. So assuming four it would look like this:
<?php
require_once('includes/test.inc');
//set page specific variables
$pgtitle = "OMGMA Test Page";
$css1 = "../main.css";
$css2 = "../other.css";
$css3 = "../yetanother.css";
$css4 = "../onemore.css";
do_html_header($pgtitle,$css1, $css2, $css3, $css4);
?>
</head>
<body>
So how could I then modify the do_html_header() so that it would print out a link to each of the variables but not print a link for variables that didn't exist? So if I specified two files I get two links, if I specify four I get four.
Would I do it like this? Or is there a better way?
<?php
function do_html_header($title, $style1, $style2, $style3, $style4)
{
// print an HTML header
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<title><?php echo $title; ?></title>
<?php
if $style1 {
echo "<link rel='stylesheet' type='text/css' href='".$style1 ."'>";
}
if $style2 {
echo "<link rel='stylesheet' type='text/css' href='".$style2 ."'>";
}
if $style3 {
echo "<link rel='stylesheet' type='text/css' href='".$style3 ."'>";
}
if $style4 {
echo "<link rel='stylesheet' type='text/css' href='".$style4 ."'>";
}
//close of function:
}
?>