How-to articles, tricks, and solutions about PHP

How to install MySQLi on MacOS

To install MySQLi on a Mac, you will first need to install the MySQL database server on your machine.

How to install PHP composer inside a docker container

To install PHP Composer inside a Docker container, you will need to do the following:

How to install PHP intl extension in Ubuntu 14.04

To install the PHP intl extension on Ubuntu 14.04, follow these steps:

How to install php-redis extension using the official PHP Docker image approach?

To install the php-redis extension using the official PHP Docker image, you can use the docker-php-ext-install script that comes with the image.

How to JSON Decode a String into an Array with PHP

This is a short guideline that provides comprehensive information on how to decode a JSON string into an array with the help of PHP.

How to let PHP to create subdomain automatically for each user?

To automatically create a subdomain for each user in PHP, you can use the following steps:

How to list files and folder in a dir (PHP)

In PHP, you can use the scandir() function to list the files and directories in a directory.

How to locate the php.ini file (xampp)

The location of the php.ini file depends on how you installed XAMPP.

How to Log Errors and Warnings in a File with PHP

With the help of this snippet, you can learn how to log errors and warnings in a file in PHP. Go ahead and check out the examples.

How to make a countdown using PHP

One way to make a countdown using PHP is to use the time() function, which returns the current timestamp, and subtract a future timestamp (representing the end date and time of the countdown) from it.

How to Make Laravel Eloquent "IN" Query?

You can use the whereIn method on a query builder instance to create an "IN" clause for a given column and values.

How to match whitespace, carriage return and line feed using regular expression in PHP?

In PHP, you can match whitespace, carriage return, and line feed using the following regular expression:

How to Measure Script Execution Time in PHP

In this snippet, we demonstrate the simplest way of measuring the execution time of a string in PHP. Read on and check out the examples.

How to minify php page html output?

To minify HTML output in PHP, you can use the following steps:

How to Modify Session Timeout in PHP

In this short snippet, we will represent to you how to modify the session time out with the help of PHP functions.

How to output (to a log) a multi-level array in a format that is human-readable?

There are a few different ways you can output a multi-level array in a human-readable format, depending on what you mean by "human-readable" and what you want to achieve.

How to output the response HTML data by a jQuery AJAX request?

In a jQuery AJAX request, you can output the response HTML data using the .html() method.

How to Parse XML with PHP

XML (Extensible Markup Language) is used to store and transport data. Learn how to accurately parse XML with PHP simpleXML library in this simple snippet.

How to Pass an Array in URL Query String with PHP

In this short tutorial, you will find the way of passing an array in URL query string using PHP.

How to pass an array via $_GET in php?

In PHP, arrays can be passed in the URL using the $_GET superglobal variable, but they need to be encoded first using the http_build_query() function.

How to pass php variable's value to jquery

You can pass a PHP variable's value to jQuery by using the PHP variable in a JavaScript script, and then accessing it with jQuery.

How to Pass Variables by Reference in PHP

Working with variables is an essential part of a developer’s life. In this snippet, we will demonstrate to you how to pass variables by reference with PHP.

How to Prevent SQL Injection in PHP

If you want to learn how to prevent SQL injection in PHP, as well as to get comprehensive information about SQL injections, you are in the right place.

How to print a debug log?

To print a debug log in PHP, you can use the echo function to output a string to the web page or the print_r function to output the contents of a variable.

How to print all information from an HTTP request to the screen, in PHP

In PHP, you can use the $_SERVER superglobal array to access information about the current HTTP request.