How-to articles, tricks, and solutions about PHP

How to find my php-fpm.sock?

To find your PHP-FPM socket file, you will need to first determine the location of your PHP installation.

Changing permissions via chmod at runtime errors with "Operation not permitted"

It sounds like you are trying to use the chmod command to change the permissions on a file, but you are encountering an error that says "Operation not permitted".

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.

CURL and HTTPS, "Cannot resolve host"

It sounds like you are trying to use curl to make a request to an HTTPS url and are encountering an error that says "Cannot resolve host." This error can occur for a few reasons:

Upload DOC or PDF using PHP

To upload a DOC or PDF file using PHP, you will need to use the move_uploaded_file function.

PHP function to build query string from array

In PHP, you can use the http_build_query function to create a URL encoded query string from an array.

php/mySQL on XAMPP: password for phpMyAdmin and mysql_connect different?

The password for accessing phpMyAdmin and the password for connecting to the MySQL server using the mysql_connect() function can be different.

Best practice multi language website

One best practice for implementing a multi-language website in PHP is to use a language detection library such as Text-Language-Detect.

How to install PHP composer inside a docker container

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

ReflectionException: Class ClassName does not exist - Laravel

This error message indicates that Laravel is trying to use a class that it can't find.

Reloading .env variables without restarting server (Laravel 5, shared hosting)

In Laravel 5, you can use the php artisan config:cache command to compile all of your configuration into a single file, which will be loaded quickly by the framework.

How to use wget in php?

You can use the exec function in PHP to execute the wget command.

How do you remove an array element in a foreach loop?

It is generally not recommended to remove array elements while iterating over the array using a foreach loop, because the loop will behave unexpectedly when elements are removed.

Laravel 5 How to switch from Production mode

To switch from production mode to development mode in Laravel 5, you can use the php artisan down command.

How to get info on sent PHP curl request

To get information about a cURL request that you have sent using PHP, you can use the curl_getinfo() function.

curl posting with header application/x-www-form-urlencoded

To make a POST request using curl and include a header of Content-Type: application/x-www-form-urlencoded, you can use the following command:

How to check the presence of php and apache on ubuntu server through ssh

To check if PHP is installed on your Ubuntu system, you can use the following command:

SQLSTATE[42S22]: Column not found: 1054 Unknown column

It looks like you are encountering an error with the message "SQLSTATE[42S22]: Column not found: 1054 Unknown column".

Composer loading from cache

When you use the Composer package manager to install PHP packages, it stores a local cache of the packages that you have installed.

Getting data posted in between two dates

To get data posted between two dates in PHP, you can use a SQL query with a WHERE clause and the BETWEEN operator.

Error when preparing a multiple insert query

There are a few things that could cause an error when preparing a multiple insert query in PHP.

Can we pass an array as parameter in any function in PHP?

Yes, you can pass an array as a parameter to a function in PHP.

Fatal error: Class 'Illuminate\Foundation\Application' not found

This error message indicates that the Laravel framework is unable to find the Application class from the Illuminate\Foundation namespace.

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 convert seconds to time format?

To convert seconds to a time format in PHP, you can use the date function and specify the format you want to use.