Thread: PHP Question
View Single Post
Old 05-17-07, 12:21 PM   #12
tieros
Registered User
 
tieros's Avatar
 
Join Date: Jul 2002
Posts: 374
Default Re: PHP Question

If you're using PHP5, I'd suggest putting that core code into a class, and then putting the class file somewhere in your autoinclude path. That way, you don't need to require() or include() it, or worry about instantiation issues from other files.

A call like:
$sess = new SessionHandler();

will look in your autoinclude path for a file named SessionHandler.php, read it in if it's not already instantiated, and call it.

Putting the code in classes also keeps variable scoping a little cleaner plus a few other nice freebies. Using classes had a bit too much overhead in PHP4, but they are great in 5.
__________________
Athlon64 x2 3800@2400MHz eVGA 8800GTS 640MB eVGA NF44 SLI mATX mobo
OCZ 2GB DDR400 Gold XTC RAM Dual Samsung Spinpoint 250GB Sata HDDs in RAID 0
Aspire X-QPACK case w/Enermax EG425P-VE PSU Liteon Dual Layer DVD Burner Dual Dell FP 2001 20" LCD
tieros is offline   Reply With Quote