How to solve the “Cannot modify header information – headers already sent by…” error in your PHP applications

Today, when I updated a repository in git I realized that my co-workers -accidentally- broke a project (in CakePHP). What error was displaying? simple and a little confusing: Warning (2): Cannot modify header information – headers already sent by (output started at /app/config/database.php:1) [CORE/cake/libs/controller/controller.php, line 742] So, for solving this common PHP issue, I recommend…

The easiest way to check if an element exists with jQuery

When you need to know if an element exists in the DOM (Document Object Model), only uses this small code: <script type=”text/javascript”> (function($){ $(document).on(‘ready’, function(){ if( $(“element”).length ){ // Do something 🙂 } }); })(jQuery); </script> The length property returns the number of elements that match with our selector. For example, imagine that you have the…