I am fairly new to PHP and I was wondering if there was a standard convention to name php variables. I'm used to using camel case when naming variables, but I see a lot of underscores in PHP examples.
Is there a standard naming convention that most people use for PHP?
$buildingHeight
OR $building_height
It is really all about your preference in the case you mentioned. I prefer using underscore because it helps me read the variables better when scanning through the code, but ultimately it's up to you.
Other important things to note about PHP variables:
Must start with a letter or underscore (_).
May only be composed of alpha-numeric characters and underscores a-z, A-Z, 0-9, or _ .
I hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With