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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:19:40+00:00 2026-06-16T03:19:40+00:00

I came a cross this line of code in Codeigniter HMVC extension (by Wiredesignz),

  • 0

I came a cross this line of code in Codeigniter HMVC extension (by Wiredesignz), where a class got instantiated without getting assigned to a variable (class CI in Base.php)

The code :

class CI extends CI_Controller
{
  public static $APP;

  public function __construct() {

    /* assign the application instance */
    self::$APP = $this;

    global $LANG, $CFG;

    /* re-assign language and config for modules */
    if ( ! is_a($LANG, 'MX_Lang')) $LANG = new MX_Lang;
    if ( ! is_a($CFG, 'MX_Config')) $CFG = new MX_Config;

    parent::__construct();
  }
}

/* create the application object */
new CI;

What’s the name of this technique?
What’s the implication?

  • 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-16T03:19:42+00:00Added an answer on June 16, 2026 at 3:19 am

    This has not a name and the implication is, that the constructor is definitely doing too much. The reason one wants to create an instance of a class without referencing it is, that he only wants the constructor wants to be executed, but nothing more. This means, that the constructor “does” something, but a constructor should only ensure, that an object is in a stable/valid state and nothing more.

    In short: Don’t assume that this is a good practice. The global and self::$APP = $this confirms my opinion that this is a bad piece of code.

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

Sidebar

Related Questions

I just came a cross this nice code that makes this scatter matrix plot:
I came cross this code as shown below. how could I save existing annotation
I came cross this code as shown below.In the following code, I could able
Came across this code: <?php require_once 'HTTP/Session/Container/DB.php'; $s = new HTTP_Session_Container_DB('mysql://user:password@localhost/db'); ini_get('session.auto_start') or session_start();
I came across this Linq to Sql code in an application I am maintaining:
I have this very long exercise and I came a cross a problem in
I just came cross puppet inheritance lately. A few questions around it: is it
I'm currently designing an API and I came a cross a little problem: How
(Came up with this question in the course of trying to answer this other
Came across something like this today, and was wondering if there was an equivalent

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.