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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:33:42+00:00 2026-06-16T04:33:42+00:00

Starting a new PHP project and deciding that after a few years of PHP

  • 0

Starting a new PHP project and deciding that after a few years of PHP development, I’m thinking I should really start using PHP classes. I’m used to classes in the C++ world, so there’s a few things I’m not quite sure about when porting this knowledge over to PHP.

In C++, you can automatically access any class variables without a prefix, in PHP, it appears that you need to prefix all such accesses (variables and function) with this->. I know what this is (or at least I think so, a pointer to the current class instance), but I’m not sure whether its required or preferred, or if there is any alternatives. My class will be using other functions within the same class (ie, itself) fairly heavily, so having to type this-> every time is going to get time consuming quite quickly.

The classes themselves are likely to be singletons, so I’m not sure whether to actually use a class, or just prefix the functions with an identifier.

  • 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-16T04:33:43+00:00Added an answer on June 16, 2026 at 4:33 am

    The “pointer” (->) != C++ pointer.

    $this means the current class and instance. All variables are accessed by using $this->variable; or $this->function();.

    Static variables, and functions can be accessed using self::$variable or self::function()

    Outside the class instance, you must indicate the class instance: $foo->variable; or $foo->function();

    As far as I know, there is no way to access public/private/static/constant variables inside the class without using $this-> or self::

    In reference to using an object of functions… up to you. Are you planning on expanding the code later to add more functions? Are all the functions somewhat related? If they are singleton functions, there is no harm in just writing a function instead of a class. It really just depends on what you are trying to accomplish.

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

Sidebar

Related Questions

I'm starting a new project using Linux and PHP, but for the early dev
How to improve our productivity when starting new project using Delphi? For me, I
Starting a new big C multiplatform project, what rules should one follow to avoid
Starting a new project using EJB 3 / JPA, mainly stateless session beans and
I'm starting a new project using SF 1.4.18 and sfDoctrine & sfDoctrineGuard plugins. I
I'm relatively new to PHP and have been writing a project using what I
So, I'm starting a new project and working with php for the first time.
I'm currently starting a new project that will display user distrubuted data links in
So i'm working on a project that will be using PHP to download files
Starting to work on a new project using redis as a sub/pub system to

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.