How-to articles, tricks, and solutions about PHP

curl POST format for CURLOPT_POSTFIELDS

To make a POST request with PHP's cURL functions, you can use the CURLOPT_POST option to send POST data.

Increment value in MySQL update query

To increment a value in a MySQL update query using PHP, you can use the += operator.

How to remove duplicate values from a multi-dimensional array in PHP

To remove duplicate values from a multi-dimensional array in PHP, you can use the following approach:

How to create and download a csv file from php script?

To create and download a CSV file from a PHP script, you can use the following steps:

Ajax Upload image

To upload an image using Ajax, you can use the following steps:

How to call a function from a string stored in a variable?

To call a function from a string stored in a variable in PHP, you can use the call_user_func() function.

How to get file_get_contents() to work with HTTPS?

To get file_get_contents() to work with HTTPS, you may need to make sure that PHP has been compiled with the OpenSSL extension.

Directory index forbidden by Options directive

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.

Sending multiple data parameters with jQuery AJAX

To send multiple data parameters with jQuery's $.ajax() function in PHP, you can use the data option and set it to an object with the data you want to send.

Remove portion of a string after a certain character

There are several ways you can remove a portion of a string after a certain character in PHP.

Laravel: Error [PDOException]: Could not Find Driver in PostgreSQL

It looks like you are trying to connect to a PostgreSQL database from your Laravel application, but the PDO (PHP Data Objects) extension is not installed or enabled in your PHP environment.

How to access mysql result set data with a foreach loop

To access MySQL result set data with a foreach loop, you can use a loop like the following:

Chrome net::ERR_INCOMPLETE_CHUNKED_ENCODING error

The "net::ERR_INCOMPLETE_CHUNKED_ENCODING" error in Chrome is usually caused by a problem with the website you are trying to load.

Nginx serves .php files as downloads, instead of executing them

There are several reasons why Nginx may serve PHP files as downloads instead of executing them.

How do I add PHP code/file to HTML(.html) files?

To add PHP code to an HTML file, you will need to use PHP tags.

How to get client IP address in Laravel 5+

In Laravel, you can get the client's IP address by using the Request facade's ip method.

The openssl extension is required for SSL/TLS protection

The openssl extension in PHP is required to provide SSL/TLS support.

SQLSTATE[HY000] [1698] Access denied for user 'root'@'localhost'

This error message typically indicates that the MySQL server is unable to authenticate the user 'root'@'localhost' with the provided password.

How to set upload_max_filesize in .htaccess?

To set the upload_max_filesize directive in an .htaccess file, you can use the following code:

How to get everything after a certain character?

You can use the strstr() function to get everything after a certain character in a string.

correct PHP headers for pdf file download

To download a PDF file in PHP, you will need to use the appropriate HTTP headers.

Facebook Graph API, how to get users email?

To get the email of a user through the Facebook Graph API, you will need to follow some steps.

Doing HTTP requests FROM Laravel to an external API

To make an HTTP request from Laravel to an external API, you can use the HTTP client of your choice.

PHP 5 disable strict standards error

To disable the strict standards error in PHP 5, you can add the following line at the top of your PHP script: