PHP - Problems of style
It’s a matter of style and convenience to produce our php scripts in such a way that make them easy to read and debug. If we use programming editor, it will be easy to identify the various parts of the code, because programming editor will highlights our code. Here are some examples:
$line = $result[’name’] . ‘ ‘ . $result[’last_name’]; // ok - easy to read/debug$line = $result[”name”] . ‘ ‘ . $result[”last_name”]; // ok, but why use double quotes if they are not necessary?
$line = “$result[name] $result[last_name]”; // ok - but much harder to read/debug - poor coding style
$line = $result[’name’] . ‘ ‘ . doSomething($result[’last_name’]); // ok - preferred method (using a function)
If we are working with any kind of a team on allowing others access to our work in the future it’s etiquette to try to make it accessible and easy on the eyes.
If we are working with any kind of a team on allowing others access to our work in the future it’s etiquette to try to make it accessible and easy on the eyes.
