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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:19:29+00:00 2026-05-23T19:19:29+00:00

Since many PHP-related questions are very basic here, I’d propose to prepare a collection

  • 0

Since many PHP-related questions are very basic here, I’d propose to prepare a collection of tips and tricks.

This might be a starting point:

  • Check as much input parameters of as much methods as possible (see assert()).
  • Log all errors to a log-file and visualize it using your admin backend (see set_error_handler()).
  • Use type-hints as often as possible (see type-hinting)
  • Set the error level to the absolute maximum. Then code in such a way, that not a single warning appears (see error_reporting()).
  • Learn why and how PHP implements and converts data types (see type juggling and string conversions)

Thus the question is: What should PHP newbies better do?

UPDATE-1

Since quite some people reviewed this question, I’d propose to reopen it. Please click on the respective link below.

  • 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-23T19:19:30+00:00Added an answer on May 23, 2026 at 7:19 pm

    Test

    You should better test your code, probably practicing TDD. You can do this thanks to PHPUnit. Keep in mind Uncle Bob’s three rules to practice TDD.

    1. You are not allowed to write any production code unless it is to make a failing unit test pass.
    2. You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures are failures.
    3. You are not allowed to write any more production code than is sufficient to pass the one failing unit test.

    You must begin by writing a unit test for the functionality that you
    intend to write. But by rule 2, you can’t write very much of that unit
    test. As soon as the unit test code fails to compile, or fails an
    assertion, you must stop and write production code. But by rule 3 you
    can only write the production code that makes the test compile or
    pass, and no more.

    If you think about this you will realize that you simply cannot write
    very much code at all without compiling and executing something.
    Indeed, this is really the point. In everything we do, whether writing
    tests, writing production code, or refactoring, we keep the system
    executing at all times. The time between running tests is on the order
    of seconds, or minutes. Even 10 minutes is too long.

    You should try to have high code coverage. PHPUnit can also do code coverage analyses thanks to xdebug. Refactoring code that is smelly(list) should be easy, because of your test-cases which are already present.

    Security

    • Learn OWASP top 10
    • Learn PDO to prevent SQL-injections.
    • Learn Filter to prevent XSS.
    • Learn how to prevent CSRF.
    • Learn about http-only cookies and how to use in PHP.

    Performance

    • Learn and use APC

    Caching the compiled bytecode of PHP scripts to avoid the overhead of
    parsing and compiling source code on each request (some or all of
    which may never even be executed). To further improve performance, the
    cached code is stored in shared memory and directly executed from
    there, minimizing the amount of slow disk reads and memory copying at
    runtime.

    • Learn to use distributed memory caching system like Redis or Memcached.
    • Learn to just tackle low hanging fruit and forget about silly micro-optimizations.

    The famous quotation, “We should forget about small efficiencies, say
    about 97% of the time: premature optimization is the root of all
    evil”, by Donald Knuth,6 has also been mistakenly attributed to
    Hoare (by Knuth himself), although Hoare disclaims authorship.

    • Understand that PHP is just a tool in your toolbox and is not the best solution for all your problems. For example hanging requests(long-polling) can not be implemented efficiently in PHP and that’s why Facebook decided to implement chat in Erlang instead of PHP.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Since I'm sure many people have different standard, I've made this post a community
Since upgrading to 2008 I and many people here have noticed that randomly VS
Since asp.net mvc did away with many controls that were in webforms, does this
Even this must have been be asked many times, I will ask again since
As far as I know, only PHP can't be used for this. But since
I did not want to post this question since there are so many posts
There are many similar questions out there but I believe this one is unique.
Forgive me if this is a stupid question; it's been many years since I've
I found this while searching for how to fake multiple inheritance in PHP (since
Since many years a GUI-standard are the menu-bars of applications with menus popping up,

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.