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

  • Home
  • SEARCH
  • 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 355753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T12:02:50+00:00 2026-05-12T12:02:50+00:00

My site is pretty large and I do not use PHP Classes, I do

  • 0

My site is pretty large and I do not use PHP Classes, I do not understand OO good enough yet to re-write my site to use them however I would really like to use the
__autoload($class_name) feature that classes use. I rely a lot on functions, I have different function files,
forums.inc.php
blogs.inc.php
user.inc.php
photos.inc.php
general.inc.php

All these files are just functions specific to a certain part of the site, except general.inc.php would have functions that need to be on ever page.

Now is there anyway I could use autoload or make something similar that would load these function files? I once thought about doing it based on the URL, like if the URL had the word forums in it, I would load the forums function file but this would not always work as ever file related to forums does not have the word forum in there URL.

Am I pretty much out of options until I learn to code OO good enough to put all my functions into classes?

//example of the autoload 
function __autoload($class_name){
    include('classes/' . $class_name . '.class.php');
}
$time = new time();
$time->fn1();
  • 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-12T12:02:50+00:00Added an answer on May 12, 2026 at 12:02 pm

    I don’t think you can, to be honest, not in a straightforward way. In any case, wouldn’t it be way nicer to use utility classes? There’s nothing to the OOP, look at this:

    <?php
        class HTMLUtil {
        
            public static function filter($str) {...}
            public static function entities($str) {...}
            public static function encode($str) {...}
            ...etc...
        }
    ?>
    

    Static Helper/Utility classes that group together related functionality are simple to put together, just declare your functions as static:

    Declaring class members or methods as
    static makes them accessible without
    needing an instantiation of the class.

    Now you can use __autoload. You don’t have to instantiate those classes to use any of their static functions, and it makes your code more readable (if slightly more verbose). I always find it more satisfying to do something like:

    echo HTMLUtil::filter($str);
    

    instead of:

    echo filter($str); //scary filter function, where are you from?
    

    If needed, you can also declare a private constructor in your utility classes to prevent them from being instantiated, to emphasize that their ‘just a bunch of related functions’:

    private __construct() {...}
    

    To call a static function from another function within the same class you would do so using the self keyword (which references the same class, and not object or class instance):

    public static function foo()
    {
        echo self::bar() . '..and some foo';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 213k
  • Answers 213k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Worked out the answer. There must be some sort of… May 12, 2026 at 10:33 pm
  • Editorial Team
    Editorial Team added an answer Check out the DBI module. In fact, there's a whole… May 12, 2026 at 10:33 pm
  • Editorial Team
    Editorial Team added an answer You need to be more specific about the requirements: Do… May 12, 2026 at 10:33 pm

Related Questions

What's the most important consideration when deciding how to partition your application into assemblies?
I know I'll get a thousand Depends on what you're trying to do answers,
Before anyone suggests scrapping the table tags altogether, I'm just modifying this part of
I'm currently in the process of setting my website, largely with php. Though this

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.