Jessica Posted September 5, 2007 Share Posted September 5, 2007 I always name my class files ClassName.php. I see a lot of people name them ClassName.class.php Why is this? Quote Link to comment https://forums.phpfreaks.com/topic/68121-why-use-classphp-instead-php/ Share on other sites More sharing options...
roopurt18 Posted September 5, 2007 Share Posted September 5, 2007 It's just a naming convention that some people like. I personally don't see the need for it because classes should be placed in a directory appropriately named...ahem...class or classes. Quote Link to comment https://forums.phpfreaks.com/topic/68121-why-use-classphp-instead-php/#findComment-342454 Share on other sites More sharing options...
Jessica Posted September 5, 2007 Author Share Posted September 5, 2007 Yeah I keep all mine in a /lib folder. Quote Link to comment https://forums.phpfreaks.com/topic/68121-why-use-classphp-instead-php/#findComment-342459 Share on other sites More sharing options...
cmgmyr Posted September 5, 2007 Share Posted September 5, 2007 I usually do this: "class.mysql.php" ...even though I usually keep all of the classes in /includes/classes, but I just think it's neater. Whatever floats your boat! Quote Link to comment https://forums.phpfreaks.com/topic/68121-why-use-classphp-instead-php/#findComment-342526 Share on other sites More sharing options...
Jessica Posted September 6, 2007 Author Share Posted September 6, 2007 why do you add .mysql? Quote Link to comment https://forums.phpfreaks.com/topic/68121-why-use-classphp-instead-php/#findComment-342540 Share on other sites More sharing options...
cmgmyr Posted September 6, 2007 Share Posted September 6, 2007 that would be for my mysql class. Quote Link to comment https://forums.phpfreaks.com/topic/68121-why-use-classphp-instead-php/#findComment-342543 Share on other sites More sharing options...
sneamia Posted September 6, 2007 Share Posted September 6, 2007 that would be for my mysql class. As in class.*className*.php? Quote Link to comment https://forums.phpfreaks.com/topic/68121-why-use-classphp-instead-php/#findComment-342550 Share on other sites More sharing options...
cmgmyr Posted September 6, 2007 Share Posted September 6, 2007 correct Quote Link to comment https://forums.phpfreaks.com/topic/68121-why-use-classphp-instead-php/#findComment-342553 Share on other sites More sharing options...
sneamia Posted September 6, 2007 Share Posted September 6, 2007 Tricky, tricky. Switching around the order on us. Quote Link to comment https://forums.phpfreaks.com/topic/68121-why-use-classphp-instead-php/#findComment-342557 Share on other sites More sharing options...
cmgmyr Posted September 6, 2007 Share Posted September 6, 2007 haha, i just think it looks neater Quote Link to comment https://forums.phpfreaks.com/topic/68121-why-use-classphp-instead-php/#findComment-342559 Share on other sites More sharing options...
Jessica Posted September 6, 2007 Author Share Posted September 6, 2007 Ah I see. Quote Link to comment https://forums.phpfreaks.com/topic/68121-why-use-classphp-instead-php/#findComment-342573 Share on other sites More sharing options...
ToonMariner Posted September 6, 2007 Share Posted September 6, 2007 I name my classes xxx.cls.php and if yyy extends or xxx, xxx_yyy.cls.php just the naming convention I use (helps with the __autoload I use). Hope we are all on php 5 and using the __autoload function (which I think is the best function ever added to php!) save syou so much time and ensures you don't go including all kind of rubbish you don't need. Quote Link to comment https://forums.phpfreaks.com/topic/68121-why-use-classphp-instead-php/#findComment-342589 Share on other sites More sharing options...
Jessica Posted September 6, 2007 Author Share Posted September 6, 2007 *sheepish* I use PHP5 but I don't know about autoload...heading the manual Quote Link to comment https://forums.phpfreaks.com/topic/68121-why-use-classphp-instead-php/#findComment-342603 Share on other sites More sharing options...
trq Posted September 6, 2007 Share Posted September 6, 2007 I just wish __autoload() worked with functions as well. Quote Link to comment https://forums.phpfreaks.com/topic/68121-why-use-classphp-instead-php/#findComment-342614 Share on other sites More sharing options...
Jessica Posted September 6, 2007 Author Share Posted September 6, 2007 Oh sweet. Quote Link to comment https://forums.phpfreaks.com/topic/68121-why-use-classphp-instead-php/#findComment-342627 Share on other sites More sharing options...
ToonMariner Posted September 6, 2007 Share Posted September 6, 2007 I love autoload so much I am gutted you can only use it once Quote Link to comment https://forums.phpfreaks.com/topic/68121-why-use-classphp-instead-php/#findComment-342789 Share on other sites More sharing options...
448191 Posted September 6, 2007 Share Posted September 6, 2007 http://nl3.php.net/spl_autoload_register Quote Link to comment https://forums.phpfreaks.com/topic/68121-why-use-classphp-instead-php/#findComment-343036 Share on other sites More sharing options...
redbullmarky Posted September 6, 2007 Share Posted September 6, 2007 my naming conventions are like this for the same reason ToonMariner suggested - autoload. I have a 'libs' directory, typical files like: class.mysql.php - class called 'mysql' base.component.php - class called 'component' but generally a base/abstract class rather than one that should be used alone. funcs.general.php - general functions funcs.math.php - just as it says. it generally just means shaving time off actually finding stuff as well as allowing more automation when including relevent files. Quote Link to comment https://forums.phpfreaks.com/topic/68121-why-use-classphp-instead-php/#findComment-343087 Share on other sites More sharing options...
matthewhaworth Posted September 9, 2007 Share Posted September 9, 2007 As people have touched on earlier, I believe the postfix .class.php is applied to avoid confusion when using the __autoload magic function. Just a guess. But say I used display php pages parallel to classes then the confusion would arise when I have members.php and members.php; the former being a page that displays the members using the members class to works with a DAO to return all necessary information. Think of phpBB they do something.. similar.. however they separate their classes, well, includes, with a folder. So meh. Quote Link to comment https://forums.phpfreaks.com/topic/68121-why-use-classphp-instead-php/#findComment-344822 Share on other sites More sharing options...
Ninjakreborn Posted September 11, 2007 Share Posted September 11, 2007 I just like naming them myself like redbully does except reverse. math.class.php pdf.class.php For all of my classes. files.function.php whatever.function.php Quote Link to comment https://forums.phpfreaks.com/topic/68121-why-use-classphp-instead-php/#findComment-346320 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.