"Bruce W...1" <br***@noDirectEmail.com> wrote in message
news:3F**************@noDirectEmail.com...
Paulus Magnus wrote:
It isn't good programming style to use one PHP file per HTML page.
Classes should be based on functionality, as should PHP files. If all your pages
were to do with a membership system then you should have a Member class
with methods appropriate to that functionality.
If you've got a group of functions that perform similar actions you
should include them in a functions.member.inc.php file and include them where
you need them. You should group functions/methods by functionality rather
than per page as it will reduce the repetition element, imo.
Paulus
================================================== ==============
That makes sense I guess, if the functions are used by more than one page.
That still doesn't answer my original question but thats okay.
I'm also trying to make sense out of the file names. In a system where
every file can be named whatever.php there needs to be some organization. So I
was going to have a codebehind file for each page named whatever.cb.php.
May I ask what are your file naming conventions? functions.member.inc.php
is one of them.
I tend to put my classes in a single file called class.name.php and place
them in a /classes directory on the site. I then usually have two other
files in the site root, globals.inc.php and common.inc.php. Common.inc.php
contains all the basic functions I use on multiple pages and also includes
globals.inc.php. Globals.inc.php is just a list of variables and constants
for the site that contains MySQL information, site URL and paths, etc. Every
PHP file on the site then includes common.inc.php, which in turn includes
globals.inc.php.
I don't use any external files for functions. If a function is required
across pages I write a class otherwise it sits in the actual page. I also
don't have any HTML in my PHP pages, they're pure PHP and all the template
stuff is in a collection of tpl.name.php files that the pages include as
necessary. Separating the design from the logic is a big time saver and big
bug reducer.
Going back to your original question...
To call a method from an included file you need to include it, instantiate
the class and then call the method;
require ("class.name.php");
$myclass = new FunkyClass;
$myclass->method_name ();
If the class was in the same PHP file you wouldn't need the require
statement.
If you wanted to call a function from an included file you need to include
it and call it;
require ("functions.member.php");
funky_function ();
And same again, if the function is in the same PHP file, no require
statement is needed.
Paulus