If I wanted to write a really long variable name like:
$this_is_my_variable_that_does_something_in_the_following_function_and_provides_some_information_with_which_the_function_relies_upon_to_do_all_the_work_it_needs = null;
would that work? same question for function/method names
So, is there a limit in size to a Php variable to stores value, in this case, a string ? Yes. A string can be as large as up to 2GB (2147483647 bytes maximum). You can override this limit by increasing memory_limit directive in php.
It doesn't matter.
ANSI standard recognizes a length of 31 characters for a variable name. However, the length should not be normally more than any combination of eight alphabets, digits, and underscores.
Descriptive variable names should be between 8-20 characters. This is not a restriction, but just a guideline for the length of variable names. If it's too long, then it's really hard to type. If it's too short, it may not be descriptive enough.
Generally, such a limit is imposed by the threat of violence from other folks who interact with your code.
From the documentation:
Variable names follow the same rules as other labels in PHP. A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores
The same is the case for function names, as stated here.
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