What are some PHP mistakes that you should absolutely avoid as a PHP beginner?

There are plenty mistakes that you can make as a developers, plenty of them unrelated to the programming language you are using. Let's see:
  • Never ever ever ever use ‘eval’ - it will open a can of worms you don't want to deal with
  • Do not trust user input, a.k.a. always sanitize input - make sure you escape and validate any user input before actively using it (using it in a DB query, writing to a file etc.)
  • Pay attention to your coding style - great code might (and usually does) take a 3-steps process: write code that works, improve the code to be easy to read and maintain and optimize the code
  1. The first is easy and it just takes a bit of practice, nothing much to say here
  2. Refactoring code to make it easy to read and maintain takes more experience than the first step. It requires attention to details about the various sets of principles (SOLID, DRY, simplicity and common sense), about the side effects of each function/method you write, about the seggregation between the internal logic of you code and the API it exposes. This is a large topic, subject of other questions already asked on Quora
  3. Optimize code - again, something that comes with practice.
  • Do not avoid unit tests - automated tests will solve a lot of problems for you (helps catching bugs, helps giving code a better structure, helps with the corectness of your code and so many more)
  • Use PDO instead of myslq/myslqi - it offers the same level of abstraction of a DB connection with the advantage of OOP style
  • Do not reinvent the wheel - the community is filled with solutions that people already thought of to problems you haven't encountered first. Use them, don't attempt to reinvent the wheel. But make sure you understand how they work. Copy-Paate oriented programming will keep you in the begginner area longer than you think
  • Write code - don't be afraid to experiment, try things just out of curiousity if nothing else. Practice is the key

I think I left here a list of advices more than a list of mistakes to avoid. And I could go on and on about things that developers don't do right. At the end of the day, all this can be summarized in one simple principle: learn and practice constantly. Doing so will not guarantee that you won't make mistakes (everybody did, does and will do), but it will definitely take you through all the steps of the process.

COMMENTS

Name

5G,1,Business,2,Bussiness,3,C,2,C++,4,CodeProject,3,Companies,5,Computer,1,Dev.to,1,Facebook,1,Future,2,Google,4,Javascript,2,Microsoft,2,Motivation,6,PHP,3,Programmer,6,Programming,13,Projects,1,Python,3,Quantum,1,Quora,10,Software Development,3,Tech,4,VS Code,2,
ltr
item
9to5Programmer: What are some PHP mistakes that you should absolutely avoid as a PHP beginner?
What are some PHP mistakes that you should absolutely avoid as a PHP beginner?
There are plenty mistakes that you can make as a developers, plenty of them unrelated to the programming language you are using.
https://i.imgur.com/rtnjTds.png
9to5Programmer
http://www.9to5programmer.com/2019/02/php-mistakes-that-you-must-avoid.html
http://www.9to5programmer.com/
http://www.9to5programmer.com/
http://www.9to5programmer.com/2019/02/php-mistakes-that-you-must-avoid.html
true
1435496506228626257
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy