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

  • Home
  • SEARCH
  • 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 1080361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:01:05+00:00 2026-05-16T22:01:05+00:00

What are valid reasons NOT to use keywords public, private, protected in php? The

  • 0

What are valid reasons NOT to use keywords public, private, protected in php?

The story: I’ve started a project with a team that actively uses access modifiers in their code (even “public” explicitly) and wants to convince me to do the same. I always find this kind of stuff totally useless in a dynamic language like php, but I realize that my gut feeling is hardly an argument in a technical discussion. Therefore I’m looking for a solid, clear explanation why access modifiers are useless (or even harmful) in php.

I’m aware that some similar topics already exist

  • Importance of protected/private in PHP classes
  • Why not use 'protected' or 'private' in PHP?
  • Best to use Private methods or Protected methods?

however there are several reasons why I’m posting this one

  • I am not asking if I should use “public” or not. I’m already not using it.
  • I am explicitly not interested to hear why access modifiers are good (I know they’re bad, I just need an expert to confirm that).
  • If you’re about telling me about “best practices” and “principles of OOP”, please do not bother.

TIA

  • 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-16T22:01:06+00:00Added an answer on May 16, 2026 at 10:01 pm

    mario nailed it (copied from the comments)

    Access modifiers make sense in Java/C++ and compiled code in general, where they are enforceable. In uncompiled scripting languages they can easily be ripped out. Hence they should be considered just decorators, and thus pragmatically could just be implemented as coding convention. (See underscoritis in Python, and pretty much any other scripting language. PHP is pretty alone with its purposeless access decorators.)

    You won’t have much success convincing your teammates about the advantage of useful APIs over encapsulation by restrictiveness. The use of syntax-enforced access decorators is often cargo cult driven.

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

Sidebar

Related Questions

My question may not make sense but I have valid reason. We use .net
Is this valid and correct? RewriteRule ^myOldPage.html$ /index.php#info [R] I'm specifically interested about the
Edit: There appears to be at least two valid reasons why Smalltalkers do this
Are forms that use the POST method required to have CSRF protection? I'm following
I want to use autocomplete-fields that link to an external source for their autocomplete-data.
I'm currently doing some oracle sql analysis and often encounter valid sql statement that
A valid JSON Syntax is something of the kind: { username: admin, password: 123
With valid HTML the following finds the object as expected in all browsers but
Given an existing valid SVG document, what's the best way to create informational popups,
What characters are valid in a Java class name? What other rules govern Java

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.