DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
  1. DZone
  2. Coding
  3. Languages
  4. Avoid legacy programming practices in PHP 5.4: the underscore lesson from PHP4/5

Avoid legacy programming practices in PHP 5.4: the underscore lesson from PHP4/5

John Esposito user avatar by
John Esposito
·
Oct. 28, 11 · Interview
Like (0)
Save
Tweet
Share
5.15K Views

Join the DZone community and get the full member experience.

Join For Free

Old habits die hard; old language habits die harder; old programming habits die hardest, especially when the habit first developed from a defect in the language.

So as PHP5.4 approaches, it's a good idea to take stock of the habits you may have developed in previous versions of PHP.

Volker Dusch addresses one of these habits: the 'privatizing underscore', an old dodge designed to keep variables private in the programmer's head -- because PHP4 couldn't keep variables private on its own.

PHP 5 offeredprivate variables, so nobody really needed underscores anymore. But plenty of apps were still written in PHP4; and, besides, lots of coders were used to those underscores, so they kept on using them anyway.

But now PHP4 has mostly disappeared. It's to act like it's gone, declares Volker:

We are deep into 5.x now and it’s time to get rid of your PHP 4 legacy. The last release was 3 years ago, the number of people that still admit to using it in production dropped below the care ratio and all major frameworks and libs migrated.


The real point is that retaining legacy programming practices past due date can only lead to rotten code. (For example, what if you need to make a variable public? 'Replace all in project'?)

Volker's sage advice is: every new language release is an opportunity to move on. But, more specifically, stop talking in underscores to PHP4 users that no longer exist.

Read the rest of his post here.


PHP

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • The 5 Books You Absolutely Must Read as an Engineering Manager
  • How To Handle Secrets in Docker
  • Spring Boot vs Eclipse MicroProfile: Resident Set Size (RSS) and Time to First Request (TFR) Comparative
  • Reliability Is Slowing You Down

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: