How-to articles, tricks, and solutions about PHP
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.
In Zend Framework, you can use the Zend_Db_Select object's __toString() method to print the exact SQL query that will be executed.
On this page, we will illustrate how to use PHP echo for printing JavaScript console. Here, you will find several options for different occasions.
To set up a PDO connection, you will need to do the following:
In this short tutorial, you will find comprehensive solutions on how to push both value and key into a PHP array.
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.
In this tutorial, you can find comprehensive information on how to read whether a checkbox is checked in 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.
In Laravel, you can use the refresh method on a model instance to reload the model's attributes from the database.
To remove "index.php" from the URL in CodeIgniter, you can use the .htaccess file.
On this page, you will find practical and comprehensive information on how to remove a cookie with the help of PHP.
To remove a variable from a PHP session array, you can use the unset() function.
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.
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.
You can use the JSON_UNESCAPED_SLASHES option in the json_encode() function to prevent backslashes from being added to the JSON string.
To remove duplicate values from a multi-dimensional array in PHP, you can use the following approach:
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.
To remove the extension from a string in PHP, you can use the pathinfo() function and the basename() function.
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.
There are a few different ways to remove line breaks from a string in PHP. Here are two options.
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.
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.
In this short tutorial, we are going to represent to you a solution to a common PHP issue: how to remove warning messages easily.
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.
Here's how you can replace an "if" statement with a ternary operator in PHP.