![]() |
Grrr Functions
Hi
I have a config file, conf_global.php with all sorts of settings and variables. The one I am interested at the moment is $siteName = 'A Site Name';I include conf_global.php on every page. I also, in this file, link to core.func.php, which is a file with all my functions in it. I have a function, called title(): PHP Code:
PHP Code:
PHP Code:
Gareth |
How are you including those two files?
It should work like so: PHP Code:
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:
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:
HTH |
not sure if it will work but try:
PHP Code:
|
In your configurations file;
PHP Code:
PHP Code:
PHP Code:
|
Thank you everyone for your help! I just had to make $siteName global :)
Gareth |
| All times are GMT. The time now is 07:27 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0