Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 136263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:55:15+00:00 2026-05-11T06:55:15+00:00

Good design dictates only writing each function once. In PHP I’m doing this by

  • 0

Good design dictates only writing each function once. In PHP I’m doing this by using include files (like Utils.php and Authenticate.php), with the PHP command include_once. However I haven’t been able to find any standards or best practices for PHP include files. What would you at StackOverflow suggest?

I’m looking for:

  • Naming Standards
  • Code Standards
  • Design Patterns
  • Suggestions for defining return types of common functions (now I’m just using associative arrays).
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T06:55:15+00:00Added an answer on May 11, 2026 at 6:55 am

    One convention I like to use is to put each class in its own file named ClassName.class.php and then set up the autoloader to include the class files. Or sometimes I’ll put them all in a classes/ subdirectory and just name them ClassName.php. Depends on how many class vs. non-class includes I’m expecting.

    If you organize your utility functions into classes and make them static methods instead, you can get away with writing only a single require_once() in your top level files. This approach may or may not be appropriate for your code or coding style.

    As for return types, I try to follow the conventions used in the built-in functions. Return a type appropriate to the request, or return false on failure. Just make sure you use the === operator when checking for false in the results.

    The fact that you’re concerned about conventions suggests you’re already on the right track. If you are familiar with any other OOP language like Java, C++, C#, etc., then you’ll find you can follow a lot of the same conventions thanks to the OOP goodness in PHP5.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

considering good design, is it better for each view controller to manager their own
What is good design in this simple case: Let's say I have a base
Is this good OO Design assuming you want every inheriting class to be a
Would using MVC to write a serious game be good design and a smart
This question is more aimed at good design practices rather than exceptions and stacks.
This question pertains primarily to good design. Suppose I have a controller action like
I'm wondering if this is a good design. I have a number of tables
I'm looking for a good design pattern/strategy for how to using the Struts 2
I've heard people saying that good design involves using inheritance instead of littering your
We need some input on what is a good design pattern on using AJAX

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.