How-to articles, tricks, and solutions about PHP

php - Unknown: Failed opening required on line 0. laravel 5.6

This error message is typically caused by a problem with the file path specified in the "require" or "include" statement.

PHP - warning - Undefined property: stdClass - fix?

It looks like you are trying to access a property of an object that has not been defined.

PHP : Remove object from array

Here is an example of how to remove an object from an array of objects in PHP:

PHP & localStorage

PHP is a programming language that is often used to build web applications.

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:

PHP 7: Missing VCRUNTIME140.dll

It looks like you are encountering an error related to a missing VCRUNTIME140.dll file when using PHP 7.

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.

php artisan migrate - SQLSTATE[HY000] [1045] Access denied for user 'laravel'@'localhost'

This error message is indicating that the PHP script, "artisan," is attempting to run a database migration command, but the database server is denying access to the user "laravel" on the "localhost" location.

PHP Carbon, get all dates between date range?

You can use the range method of the Carbon class in PHP to get all the dates between a specific date range.

PHP check if url parameter exists

To check if a URL parameter exists in PHP, you can use the isset function.

PHP class: Global variable as property in class

You can use the global keyword to access a global variable inside a class.

PHP CLI won't log errors

There are a few things that can cause errors to not be logged when running PHP from the command line interface (CLI).

PHP code to get selected text of a combo box

To get the selected text of a combo box (also known as a dropdown menu or select box) in PHP, you can use the following code:

PHP Composer update "cannot allocate memory" error (using Laravel 4)

This error can occur when the composer process is trying to allocate more memory than is available to it.

PHP Connection failed: SQLSTATE[HY000] [2002] Connection refused

The error message "SQLSTATE[HY000] [2002] Connection refused" typically indicates that the client was unable to establish a connection to the database server.

PHP convert string to hex and hex to string

To convert a string to its hexadecimal representation, you can use the bin2hex function in PHP.

PHP create PDF invoice

There are several libraries available in PHP that can be used to create PDF invoices, such as TCPDF and FPDF.

PHP CURL DELETE request

To send a DELETE request with PHP using cURL, you can use the following code:

PHP cURL how to add the User Agent value OR overcome the Servers blocking cURL requests?

You can add a custom User Agent value to a cURL request in PHP using the CURLOPT_USERAGENT option.

PHP cURL HTTP CODE return 0

If cURL is returning a HTTP code of 0, it usually indicates that cURL was unable to communicate with the server.

PHP cURL HTTP PUT

To make an HTTP PUT request using PHP's cURL functions, you can use the following snippet:

php echo if two conditions are true

You can use the if statement in PHP to check if two conditions are true.

PHP Error: Function name must be a string

This error typically occurs when you are trying to call a function, but you are not passing a string as the name of the function.

php exec() is not executing the command

There could be a few reasons why the exec() function in PHP is not executing the command as expected.

PHP exec() vs system() vs passthru()

The exec(), system(), and passthru() functions are all used to execute external programs in PHP.