How-to articles, tricks, and solutions about PHP
Detecting request type in PHP (GET, POST, PUT or DELETE)
In PHP, you can use the $_SERVER['REQUEST_METHOD'] superglobal to detect the request type.
How to convert an image to Base64 encoding
To convert an image to base64 encoding in PHP, you can use the base64_encode() function
PHP append one array to another (not array_push or +)
To append one array to another in PHP, you can use the array_merge function.
String comparison using '==' or '===' vs. 'strcmp()'
In PHP, you can use either the == or === operator to compare two strings.
How to enable PHP short tags?
PHP short tags are a shortened version of the standard PHP opening tag.
Laravel 5 – Clear Cache in Shared Hosting Server
To clear the cache in Laravel 5, you can use the php artisan cache:clear command.
What is stdClass in PHP?
In PHP, stdClass is a predefined class, which is part of the PHP standard library
Difference between require, include, require_once and include_once?
In PHP, require and include are two statements that are used to include a file in a PHP script.
MySQL query to get column names?
To get the column names of a table in MySQL, you can use the SHOW COLUMNS FROM command.
How to send a GET request from PHP?
To send a GET request from PHP, you can use the file_get_contents function or the cURL extension.
Lost connection to MySQL server at 'reading initial communication packet', system error: 0
This error message indicates that the client was unable to connect to the MySQL server.
List all files in one directory PHP
To list all files in a directory using PHP, you can use the glob() function.