Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Banned
    Join Date
    Apr 2007
    Posts
    428
    Thanks
    29
    Thanked 5 Times in 5 Posts

    Including functions that may or may not be used

    Hy peeps. Having fun?

    My problem is not in php code, but in using the same code. Site i'm working on uses $_GET to move through pages, and on one page i have a contact form. Few days i thought of how to use the contact.php that lays in my includes folder to load only on contact forms page.

    Problem is that my code isn't extendable to that level, and i can't find a proper way to include that contact function only on my contact form, so i thought of just including it in the index file, and some ppl i asked told me that is ordinary habit of including all function in index file.

    For some reason i don't think that is a good idea, couse first it loads lot's of unnecessary code, and maybe somehow it can be a good path to further errors in code.

    So what do you guys think, to just include the function, or to recode everything and find a proper way of including the contact.php only when contact page is reached.

    Thanks

  • #2
    New Coder
    Join Date
    Aug 2007
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I guess it really depends on how strong your host is. See, loading the file into memory each time obviously uses excess memory, but if the site isn't massive, then it should be ok.

    The other way is to setup a permissions table, which will contain which pages have access to this contacts file you talk of, but this will still involve loading information into memory.

    Using the include won't be much of a problem in my opinion.

    Perhaps someone else can assist better..

  • #3
    Banned
    Join Date
    Apr 2007
    Posts
    428
    Thanks
    29
    Thanked 5 Times in 5 Posts
    Quote Originally Posted by PhaZZed View Post
    The other way is to setup a permissions table
    oh, i'm not using mySQL. in my free time i'm developing a new 4d database system.. Lol..

  • #4
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    and i can't find a proper way to include that contact function only on my contact form
    Explain that further.

    Why can you not just include a PHP file on a specific page?

    Just including everything on every single page is bad design and unnecessary load on the server. So I would advise against doing that.

  • #5
    New Coder
    Join Date
    Aug 2007
    Location
    Wagga, Australia
    Posts
    59
    Thanks
    0
    Thanked 1 Time in 1 Post
    Quote Originally Posted by aedrin View Post
    Explain that further.

    Why can you not just include a PHP file on a specific page?

    Just including everything on every single page is bad design and unnecessary load on the server. So I would advise against doing that.
    I agree with aedrin, but if you are insistent on doing it differently why not make a big class file that is require for every page with a big assortment of classes and functions one might need to use in their web app

  • #6
    Banned
    Join Date
    Apr 2007
    Posts
    428
    Thanks
    29
    Thanked 5 Times in 5 Posts
    Quote Originally Posted by aedrin View Post
    Why can you not just include a PHP file on a specific page?
    well my template class is rather sloppy coded. i know i can do it better, and i need few advices, so if you guys want to take a peep at it i'll post it here. I'm stuck with it couse for now it's only designed to include static pages from an array, where their titles are defined (everything is flat file). To expand it to include PHP also is a lot of work, beacoue i would like to do it in separate class, and i wouldn't even like to start it until i know that needs to be done.

    Now i know, and it needs to be done. If you want to help me figure out how to make a good template class(if you can even call it template for now), i would be glad to post the code i made so far.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •