Warning: include(nectar/meta/meta-config.php) [function.include]: failed to open stream: No such file or directory in /home/content/18/9019618/html/v2014/wp-content/themes/salient/functions.php on line 4650

Warning: include() [function.include]: Failed opening 'nectar/meta/meta-config.php' for inclusion (include_path='.:/usr/local/php5/lib/php') in /home/content/18/9019618/html/v2014/wp-content/themes/salient/functions.php on line 4650
Are You Making Any Of These Common PHP Mistakes?

Are You Making Any Of These Common PHP Mistakes?

By June 18, 2015 Blog No Comments
Are You Making Any Of These Common PHP Mistakes?

It doesn’t matter how experienced you are, mistakes happen. Some common PHP mistakes happen because you’re rushing through the process to get to the more creative part of coding that brand new feature you’ve been planning for the past few weeks, while others happen because you were actually taught that way. Today we’d like to take a closer look at what some of the most common PHP mistakes are and how to avoid them. Let’s jump right in!

Single Versus Double Quotes

While to some developers this might sound like an obvious one, quotes are one of the most common PHP mistakes out there, and you’d be surprised to find out how many developers actually use them the wrong way. What’s the big deal with quotes, anyway? Every time you put something in double quotes, you are telling PHP to check that content for a variable. So even if a line does not contain variables within the double quotes, PHP will still waste precious computing time scanning them anyway.

Are You Making Any Of These Common PHP Mistakes?Buy Theme Open Demo

Don’t Forget The Semicolon

PHP requires each statement to end with a semicolon, so unless you place “;” at the end, PHP will keep going until the next semicolon and treat everything as a single statement. However, that’s not the only potential problem when it comes to semicolons in PHP – one of the just as common PHP mistakes is misusing the semicolon. If you’re using a semicolon after a “break” or “continue” in your code, it will tell the code to output a “0” and exit.

Most Common PHP Mistakes Beginners Make

Developers often complain that PHP errors and notices annoy them, especially when they’re just starting out, which is why they usually turn error reporting off. This is one of the easiest to fix, yet most common PHP mistakes out there. Error reporting takes much of the guesswork out of debugging code, and speeds up your overall development time. You can easily log all the errors without showing them to the end-user via the php.ini file. Simply copy and paste the following lines:

display_errors: off
log_errors: on
error_log: logs/errors.log

Are You Making Any Of These Common PHP Mistakes?Buy Theme Open Demo

The secret behind effective code lies in preparation and foresight, just as much as it does in experience and knowledge. Once you’re aware of some of the most common PHP mistakes other developers make, you can avoid them much easier and actually focus on coding that stunning functionality bound to take the world by storm.

Leave a Reply