How-to articles, tricks, and solutions about PHP

How to print all properties of an object

To print all properties of an object in PHP, you can use the get_object_vars function, which returns an associative array of an object's properties.

How to print exact sql query in zend framework ?

In Zend Framework, you can use the Zend_Db_Select object's __toString() method to print the exact SQL query that will be executed.

How to Print JavaScript Console Using PHP

On this page, we will illustrate how to use PHP echo for printing JavaScript console. Here, you will find several options for different occasions.

How to properly set up a PDO connection

To set up a PDO connection, you will need to do the following:

How to Push Both Value and Key into a PHP Array

In this short tutorial, you will find comprehensive solutions on how to push both value and key into a PHP array.

How to Read Request Headers in PHP

The given snippet explores how to read request readers in PHP. Read it and learn the most helpful methods of reading any request headers in PHP.

How to Read Whether a Checkbox is Checked in PHP

In this tutorial, you can find comprehensive information on how to read whether a checkbox is checked in PHP.

How to Redirect a Web Page with PHP

In PHP, you can use several functions to make a redirect from one web page to another. Learn how to do it accurately with W3docs.

How to reload/refresh model from database in Laravel?

In Laravel, you can use the refresh method on a model instance to reload the model's attributes from the database.

How to remove "index.php" in codeigniter's path

To remove "index.php" from the URL in CodeIgniter, you can use the .htaccess file.

How to Remove a Cookie with PHP

On this page, you will find practical and comprehensive information on how to remove a cookie with the help of PHP.

How to remove a variable from a PHP session array

To remove a variable from a PHP session array, you can use the unset() function.

How to remove all non printable characters in a string?

To remove all non-printable characters in a string in PHP, you can use the preg_replace function with a regular expression pattern that matches non-printable characters.

How to Remove and Reindex an Array Element in PHP

Sometimes, in the course of working with PHP, it is necessary to remove and reindex an array element. Here, you will find simple and helpful methods to do that.

How to remove backslash on json_encode() function?

You can use the JSON_UNESCAPED_SLASHES option in the json_encode() function to prevent backslashes from being added to the JSON string.

How to remove duplicate values from a multi-dimensional array in PHP

To remove duplicate values from a multi-dimensional array in PHP, you can use the following approach:

How to Remove Empty Array Elements in PHP

Very often, it is necessary to remove empty elements of the array in PHP. This snippet will provide you with the most common and efficient way to do it.

How to remove extension from string (only real extension!)

To remove the extension from a string in PHP, you can use the pathinfo() function and the basename() function.

How to Remove Files from Folder with PHP

PHP does not have a specific undo for what you delete from anywhere. This snippet will represent how to remove files from folder permanently using PHP.

How to remove line breaks (no characters!) from the string?

There are a few different ways to remove line breaks from a string in PHP. Here are two options.

How to Remove the First Character of a String with PHP

In this short tutorial, we are going to represent to you the three main PHP functions that are used for removing the first character of a string.

How to Remove the Last Character from a String in PHP

A common issue in PHP is removing the last character from a particular string. Here, you can find the methods that will help you to deal with this problem.

How to Remove Warning Messages in PHP

In this short tutorial, we are going to represent to you a solution to a common PHP issue: how to remove warning messages easily.

How to rename sub-array keys in PHP?

You can use the array_combine function in PHP to create a new array by using one array for the keys and another for the values.

How to replace "if" statement with a ternary operator ( ? : )?

Here's how you can replace an "if" statement with a ternary operator in PHP.