PHP - Problems of style

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.

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.