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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:58:38+00:00 2026-06-04T01:58:38+00:00

What exactly is the difference in PHP classes when using the __construct constructor and

  • 0

What exactly is the difference in PHP classes when using the __construct constructor and when using the name of the class as constructor?

For example:

class Some
{
     public function __construct($id)
     {
           ....
     }
     ....
}

OR

class Some
{
      public function Some($id)
      {
            ....
      }
      ....
}
  • 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-04T01:58:40+00:00Added an answer on June 4, 2026 at 1:58 am

    The top is the new way it is done in PHP as of version 5.0 and is how all new code should be written. The latter is the old PHP 4 way and is obsolete. At some point it will be completely deprecated and removed from PHP altogether.

    Update

    As of PHP 5.3.3, methods with the same name as the last element of a namespaced class name will no longer be treated as constructor. This change doesn’t affect non-namespaced classes.

    <?php
    namespace Foo;
    class Bar {
        public function Bar() {
            // treated as constructor in PHP 5.3.0-5.3.2
            // treated as regular method as of PHP 5.3.3
        }
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to PHP OOP, and I think public $var and __construct() are exactly
What exactly is the difference between shuffle and array_rand functions in PHP? Which is
I think I'm confused about exactly what the difference is between running a PHP
If I return nothing explicitly, what does a php function exactly return? function foo()
I am using Keith Woods countdown timer (http://keith-wood.name/countdown.html) with the serverSync function. This seems
What exactly is the difference in rails between dev and prod environments. When I
Scenario I have an TWO datbase tables of exactly the SAME STRUCTURE. The difference
I have classes that are named exactly the same across different plug-ins that I
I know that in PHP, the only difference between double quotes and single quotes
I am trying to retrieve this page using curl in php. This page of

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.