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 995201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:41:13+00:00 2026-05-16T06:41:13+00:00

I am writing a pretty basic php app and have created a pretty big

  • 0

I am writing a pretty basic php app and have created a pretty big mess of functions to do various things, e.g. display_user_nav(), display_user_list() etc. I want a way to organize these in a logical way. What I really need is something like a ruby module, but I haven’t been able to find a php equivalent. I also feel that from a programming standpoint they don’t belong in classes, as I already have a User object to contain information for one user, and don’t want to have to create and store a new object whenever I want to use them.

What I am doing now:

display_user_table()
display_user_edit_form()

What I kind of want to be able to do (sort of like Ruby):

User_Functions::Display::Table()
User_Functions::Display::Edit_Form()

Any suggestions are appreciated.

  • 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. Editorial Team
    Editorial Team
    2026-05-16T06:41:14+00:00Added an answer on May 16, 2026 at 6:41 am

    If you are using PHP 5.3+, you have namespaces available.

    So you can name your functions (the namespace separator is \):

    User_Functions\Display\Table
    User_Functions\Display\Edit_Form
    

    However, it seems like using a class for this wouldn’t be a bad idea. If you feel that display functions don’t really belong to User (the same way many people think serialization methods don’t make sense in the target objects), you can create a class like this:

    class DisplayUser {
        private $user;
        function __construct(User $u) { $this->user = $u; }
        function table() { /* ... */ } 
        function displayForm() { /* ... */ } 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just writing some CSS and I have a pretty cool Search form where you
I'm making pretty heavy use of JSON parsing in an app I'm writing. Most
I have heard that MbUnit comes with pretty nice test decorators which allow writing
I'm writing a pretty basic webserver (well, trying) and while it's now serving HTML
I'm writing a pretty basic application in python (it's only one file at the
I'm currently writing some pretty basic code for a shopping cart on a webpage
This seems to be a pretty basic concept that I don't understand. In writing
I have an extremely basic Windows Forms app for data capture and reporting on
This is pretty basic question around unit testing. I have a method e.g. GetOrderDetails
I am currently writing a system for publishing tutorials about basic PHP. However, I

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.