How-to articles, tricks, and solutions about PHP

413 Request Entity Too Large - File Upload Issue

The HTTP error 413 Request Entity Too Large indicates that the server is unable to process the request because the request payload (the body of the request) is larger than the server is able to handle.

How to set php executable path vscode inside docker container?

To set the php.validate.executablePath in Visual Studio Code (VS Code) when running PHP inside a Docker container, you can follow these steps:

Convert a PHP script into a stand-alone windows executable

It is possible to convert a PHP script into a standalone Windows executable using tools such as PHPCompiler by Bambalam or PHPC.exe.

Merge PDF files with PHP

There are several ways to merge PDF files using PHP.

If else embedding inside html

There are a few different ways you can embed PHP code inside HTML.

Woocommerce get products

You can retrieve a list of products in WooCommerce using the get_products() function.

Location for session files in Apache/PHP

In Apache, the location for session files is determined by the session.save_path configuration directive in your php.ini file.

Headers and client library minor version mismatch

If you are seeing this error message in PHP, it may be caused by a mismatch between the version of the PHP client library that you are using and the version of the API that it is trying to access.

HTML/PHP - Form - Input as array

To create an HTML form that submits an array as a form parameter, you can use the name attribute of the input element and give it a value in the form of an array.

How do I PHP-unserialize a jQuery-serialized form?

In PHP, you can use the unserialize function to unserialize a serialized string.

How can I count the numbers of rows that a MySQL query returned?

You can use the mysqli_num_rows() function to count the number of rows that a MySQL query returned in PHP.

enable cors in .htaccess

To enable Cross-Origin Resource Sharing (CORS) in an .htaccess file, you can add the following lines:

Laravel Eloquent LEFT JOIN WHERE NULL

In Laravel, you can use the leftJoin method on a query builder instance to perform a left join, and then use the whereNull method to only include records where a column from the right-hand table is null:

In Laravel is there a way to add values to a request array?

Yes, you can add values to a request array in Laravel by using the merge method on the request object.

mysqli_connect(): (HY000/2002): No connection could be made

This error message typically indicates that there was a problem trying to establish a connection to the MySQL server.

How to install bcmath module?

The bcmath extension is typically installed by default in most PHP installations.

How do I remove the last comma from a string using PHP?

To remove the last comma from a string in PHP, you can use the rtrim function.

Get environment value in controller

To get an environment value in a PHP controller, you can use the getenv function.

Make var_dump look pretty

To make the output of var_dump() more readable, you can use the following approaches:

how to upload file using curl with PHP

To upload a file using cURL in PHP, you can use the curl_setopt function to specify the CURLOPT_POSTFIELDS option with the file data.

How do I return a proper success/error message for JQuery .ajax() using PHP?

To return a proper success/error message for jQuery.ajax() using PHP, you can do the following:

How to get xdebug var_dump to show full object/array

To get xdebug to show the full contents of an object or array when using the var_dump function, you can use the xdebug.var_display_max_depth setting in your php.ini file.

What is PHPSESSID?

PHPSESSID is a session cookie that is used to identify a user's session on a website.

CodeIgniter activerecord, retrieve last insert id?

To retrieve the last insert id in CodeIgniter using the Active Record class, you can use the $this->db->insert_id() method.