How-to articles, tricks, and solutions about PHP
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:
In PHP, when a class inherits from another class, it is said to be a subclass or derived class.
In PHP, you can use the str_replace function to delete a particular word from a string.
The split() function is deprecated, which means it is no longer supported and should not be used in new code.
In PHP, you can use the $_SERVER['REQUEST_METHOD'] superglobal to detect the request type.
In PHP, you can use the built-in function strtotime() to convert a date string to a Unix timestamp, which is the number of seconds since the Unix epoch (January 1, 1970).
In PHP, require and include are two statements that are used to include a file in a PHP script.
This error message typically appears when you are trying to access a directory on a web server that does not contain an index.html or index.php file and the web server is configured to prevent users from browsing the directory.
To disable strict standards in PHP 5.4, you can add the following line of code to your PHP script:
Here is an example of how you could display an array in a readable/hierarchical format in PHP:
In Laravel, you can use the withErrors method to pass error messages to a view after a redirect.
In PHP, you can divide two integers using the forward slash (/) operator.
When building a Docker image with PHP and the zip extension, you may see the warning.
The '[2002] Connection refused' error in Docker when trying to connect to a MySQL container typically indicates that the MySQL server is not running or is not accessible on the network.
To update an entry in a database using Doctrine's query builder, you can use the update method of the QueryBuilder class.
Yes, the file_get_contents function in PHP does have a timeout setting.
UTC (Coordinated Universal Time) is a standardized time that does not observe daylight saving time (DST).
To make an HTTP request from Laravel to an external API, you can use the HTTP client of your choice.
To download a large file using curl, use the following command:
Using a foreach loop to clear the values of an array in PHP is an efficient way to do so.
There are multiple ways to get the count of months between two dates in PHP, but one elegant way is to use the DateTime class and the diff() method.
To update multiple records in the Eloquent ORM (Object-Relational Mapping) in Laravel, you can use the update() method on the query builder or on a model instance.
To enable Cross-Origin Resource Sharing (CORS) in an .htaccess file, you can add the following lines:
To enable the GD extension in PHP, you will need to install the extension and then enable it in your PHP configuration file.