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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:54:47+00:00 2026-05-24T13:54:47+00:00

I’m trying to undestand how FuelPHP was written.. And since I don’t know OOP

  • 0

I’m trying to undestand how FuelPHP was written.. And since I don’t know OOP much, I’m puzzled when this class:
https://github.com/fuel/core/blob/master/classes/date.php

Here are methods that I don’t understand:

public static function _init()
{
    static::$server_gmt_offset  = \Config::get('server_gmt_offset', 0);

    // some code here
}

public static function factory($timestamp = null, $timezone = null)
{
    $timestamp  = is_null($timestamp) ? time() + static::$server_gmt_offset : $timestamp;
    $timezone   = is_null($timezone) ? \Fuel::$timezone : $timezone;

    return new static($timestamp, $timezone);
}

protected function __construct($timestamp, $timezone)
{
    $this->timestamp = $timestamp;
    $this->set_timezone($timezone);
}

What is called first? What __counctruct does? What is factory, when it’s used, what it returns – does it call itself again? Is _init called after initializing class? I’m really puzzled, can someone help me understand? Thanks

  • 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-24T13:54:48+00:00Added an answer on May 24, 2026 at 1:54 pm

    When an object is instantiated, the first method to be called is the __construct() method. This is called a constructor because it helps construct the class’s data members and do any other initializing operations before you can call other methods int eh class.

    A Factory is a creational design pattern used to create classes based on conditions that would not be known until runtime. – http://en.wikipedia.org/wiki/Factory_method_pattern

    _init() seems to be another method that this library uses to set up it’s classes.

    To further your knowledge in these areas, i suggest you read up on OOP and then design patterns.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I am trying to render a haml file in a javascript response like so:

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.