Skip to main content
Collection

Common Mistakes to Avoid in PHP

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

Created
Active
Last edited
Viewed 8k times
Part of PHP Collective
33
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
2736 votes
14 answers
262k views

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

Recommended by PHP Collective
Abdulla Nilam's user avatar
1371 votes
14 answers
219k 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
318 votes
9 answers
361k views

How can I prevent XSS with HTML/PHP?

something people often overlook, which can then cause bugs or vulnerabilities
ADyson's user avatar
147 votes
11 answers
370k 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
4k 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
1286 votes
17 answers
703k 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.1m views

How to fix "Headers already sent" error in PHP

Common problem for new PHP programmers.
Yousha Aleayoub's user avatar
153 votes
5 answers
336k 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
287 votes
10 answers
465k views

How do I log errors and warnings into a file?

Config, display and log PHP errors properly.
Yousha Aleayoub'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
  • 1
    Sorry for that. 3v4l.org/XCSpT Commented Aug 6, 2023 at 7:02