There are many ways to name variables (as you can see from the answers)
But, as a rule, they should be called such that it’s clear that just looking at the variable, what it does and what it is used in, right there and don’t need to go through thousands of lines of code to find out, and not just for those who still need to troubleshoot later, but if your code will be thousands of lines for your own good, if you yourself must fix the problem later
AND THE SAFE CONVENTIONS THAT YOU CHOOSE AGREEMENT THROUGH YOUR CODE - this cannot be repeated enough :)
Personally, I use the following:
the first part of the variable is that it is the second part is intended for what it does / is used for
and for variables needed outside a function, class, etc., the third part is for a function, class, etc., it comes from
Example:
I want to name the variable for the video thumbnail on the first page:
so I start by saying that this (lower_case) - thumbnail
then I add what it is used for (the first letter upper_case) - Video
and since I need this on the first page outside of the function that I end up with the function from which it came (shared under_score) - getVideoAll
Giving me $ thumbnailVideo_getVideoAll
That way, no matter where I look at a variable in any part of the code (HTML, PHP, etc.), I know ...
ah this is a thumbnail for the video that I am trying to show, and if for some reason it doesn’t work, I first do not need to go anywhere to check spelling, and secondly, I know exactly what function, class, which he called (getVideoAll) and can just go there for troubleshooting
If I instead called it $ tnVid, I could personally have a vague idea of what it is, but someone else who looked would not know what tn means (t) humb (n) ail, etc. d.
therefore, to troubleshoot, they will have to first look at the surrounding code to perhaps conclude that this is a likely variable for a thumbnail, and the second - thousands of lines of code to find which function, class, etc. it happened - and that the hours of operation just find what you need, even start troubleshooting - instead of 5 seconds it takes to view thumbnailVideo_getVideoAll and go - oh this is a thumbnail for the video, and I need to go to the getVideoAll function to troubleshoot