Skip to main content
The 2024 Developer Survey results are live! See the results
Collection

Common Mistakes to Avoid in PHP

A list of real issues most beginners encounter when using PHP.

Created
Active
Last edited
Viewed 5k times
Part of PHP Collective
24
2769 votes
27 answers
2.2m views

How can I prevent SQL injection in PHP?

Highly viewed and has recommended answer
Sasha's user avatar
2723 votes
14 answers
260k views

Why shouldn't I use mysql_* functions in PHP?

Recommended by PHP Collective
Abdulla Nilam's user avatar
1358 votes
13 answers
212k views

UTF-8 all the way through

This is an issue people commonly encounter if they haven't set up all the text encoding options end to end in their environment
ADyson's user avatar
314 votes
9 answers
349k views

How can I prevent XSS with HTML/PHP?

something people often overlook, which can then cause bugs or vulnerabilities
ADyson's user avatar
148 votes
10 answers
365k views

Checking if form has been submitted - PHP

people often forget to check this, leading to form-processing code running when their page first loads
ADyson's user avatar
6 votes
4 answers
3k views

Why php function doesn't update array values

A lot of people come to PHP from languages like Python or Javascript, and don't understand why, when they pass an array into a function and that function changes the array, the array somehow ends up unchanged. Knowing that PHP passes arrays by making a copy of the array by default (but not objects) is kind of important to understand what's going on.
TKoL's user avatar
1285 votes
15 answers
690k views

How can I sanitize user input with PHP?

Understanding input sanitization in PHP is crucial for beginners, as they often make mistakes in this area, which can lead to significant security issues.
nayeemdev's user avatar
830 votes
16 answers
2.0m views

How to fix "Headers already sent" error in PHP

Common problem for new PHP programmers.
Yousha Aleayoub's user avatar
148 votes
5 answers
317k views

How to use PHP's password_hash to hash and verify passwords

How to securely store and verify passwords
miken32's user avatar
3 votes
3 answers
3k views

Routing PHP 5.4+ Built-in Web Server like .htaccess

Built In PHP Web Server to behave like Apache's .htaccess.
Praveen Kumar Purushothaman's user avatar
3
  • I would support the addition of posts which cover topics found in linkedin.com/feed/update/… Commented Aug 3, 2023 at 21:16
  • 2
    @mickmackusa That link doesn't work for me. Can you edit your comment to say what the post discusses?
    – Berthold
    Commented Aug 3, 2023 at 22:58
  • Sorry for that. 3v4l.org/XCSpT Commented Aug 6, 2023 at 7:02