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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:29:17+00:00 2026-06-06T11:29:17+00:00

new to the site. Have a quick questions. It is safe or to load

  • 0

new to the site. Have a quick questions.

It is safe or to load objects in one file to call when needed, such as:

objects.php

<?php
require 'autoload.php';

//create global objects
$obj = new Object();
$obj2 = new User();
$obj = new Bus();
?>

header.php

<?php
require 'objects.php';

echo 'Hello ' . $obj2->getName();
?>

Thanks in advance.

  • 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-06-06T11:29:19+00:00Added an answer on June 6, 2026 at 11:29 am

    It’s smarter to instantiate objects only when you need them. Creating objects takes some time and some memory. You also want to be able to know exactly what objects are in use at any given execution point in your come when you come back to change something later.

    If you instantiate a bunch of objects you don’t need, you’ll inevitably find yourself wanting to make a change but having to spend time figuring out if you’ve already use $obj2 or if it’s safe to start using it on line 350. If you don’t name your objects more descriptively, you’ll also find that you’ll reuse variable names, which will cause confusion when your object doesn’t act the way you expect. For example, in your code, $obj is a Bus, not an Object. If you were expecting an object, you’d be confused.

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

Sidebar

Related Questions

I'm running MOSS 2007 and have created a new site under an existing one
Im super new to Jquery so this may be a quick one. I have
Just a quick questions. Im new to this site but this link Show/Hide multiple
So I have been experimenting with building a new site... http://zergxost.com/test.html - it will
I am building a new site, and I have a folder on desktop with
I have integrated a Custom Google Search on a new site I am working
I have designed a new web site. I have hosted it online. I want
I have just setup a new local site (localhost/pfb.net/) which has been cloned from
I have the following code snippet: using (SPSite site = new SPSite(this.ListAddress)) { using
I'm new to WordPress. I have my site (CMS) divided to several pages in

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.