Month: July 2023

Get raw SQL from laravel query builder

How to get raw SQL from laravel query builder

To get the raw SQL query from Laravel’s query builder, you can use the toSql() method. This method returns the raw SQL string that corresponds to the query being built. Here’s an example: Additinay to output last queries ran you can use this: \DB::enableQueryLog(); // Enable query log // Your Eloquent query executed by using …

How to display errors in PHP

How to display errors in PHP

To display errors in PHP, you can adjust the error reporting settings in your PHP configuration file or in your PHP script using the error_reporting() and ini_set() functions. Additionally, you can control how errors are displayed by setting the display_errors directive. Here are some common methods to display errors in PHP: Additionally, you can set …

How to check if string contains specific word PHP

How to check if string contains specific word PHP

With PHP 8 there comes a default function by which we can check if string contains specific word or not. For the lesser versions than php 8,below functions can be used. The other function which can be used is stripos() which perform case insensitive search. Please check the use of !== false is deliberate (neither != false nor === true will …