How are you including those two files?
It should work like so:
PHP Code:
<?php
require_once('conf_global.php');
require_once('core.func.php');
title( $siteName, 'Home');
?>
Is that what you're doing?
Something else to consider, you really shouldn't allow your function to use echo and actually display something to the page. The idea of functions is to create a module or engine that you can plug some value into and have another value spit out the other end. For maximum flexibility, you should do
PHP Code:
function title( $sitename, $page ) {
return $sitename . ' - ' . $page;
}
echo '<title>'. title( $siteName, 'Home' ) .'</title>';
This way you're not tied into using HTML in the function output, and you've just let yourself build a function that can be used in just about any instance. Of course with something so finely grained that it's only job is to output the page title, this may not be the best example, but when you start building more advance functions (and eventually classes) you'll see the difference. Just my opinion, YMMV.
The last thing to consider is continuity across file names, variables, etc. I notice two things in the code you provided; one, you have
conf_global.php and
core.func.php. Two naming conventions for include files. I would suggest keeping them the same, i.e. rename the functions definitions file to
core_func.php (or of course, the other way around). The second thing is similar, in your naming of
$siteName and
$sitename. It's so easy to get those two mixed up. When I build a function, I use a totally different name for the argument than the actual variable going into it, e.g.
PHP Code:
function doSomething( $s ) {
return "Here we're doing something with {$s}";
}
$myString= "data";
echo doSomething($myString);
Absolutely no ambiguity as to what value is passed vs. the internal value.
HTH