How-to articles, tricks, and solutions about PHP

Enumerations on PHP

In PHP, an enumeration is a value that is set to a fixed set of values.

Error 500: Premature end of script headers

Error 500 "Premature end of script headers" is a general error message indicating that there is a problem with the server-side script that is preventing it from executing properly.

error in your SQL syntax; check the manual that corresponds to your MySQL server

This error message is indicating that there is a problem with the SQL syntax used in the query.

Error when preparing a multiple insert query

There are a few things that could cause an error when preparing a multiple insert query in PHP.

Example of how to use bind_result vs get_result

The mysqli_stmt::bind_result() method binds variables to a prepared statement for result storage.

Execute a string of PHP code on the command line

To execute a string of PHP code on the command line, you can use the "php" command followed by the "-r" option and the string of code in quotes.

Execute root commands via PHP

It is generally not recommended to execute root commands via PHP, as it can pose a security risk to the system.

Executing multiple SQL queries in one statement with PHP

In PHP, you can execute multiple SQL queries in one statement by using the mysqli_multi_query() function.

Export MySQL database using PHP

To export a MySQL database using PHP, you can use the mysqldump command-line utility or the mysqli extension.

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.

Facebook SDK returned an error: The "state" param from the URL and session do not match

This error message appears when the SDK is being used to make an OAuth request to Facebook, and the "state" parameter in the URL doesn't match the "state" value that was stored in the user's session.

FastCGI process exceeded configured activity timeout

FastCGI is a protocol for interfacing interactive programs with a web server.

Fatal error: [] operator not supported for strings

This error is usually caused when you are trying to use the square brackets [] to access a character in a string, but this is not supported in PHP.

Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 71 bytes)

This is a PHP error message that indicates your script is trying to use more memory than the amount specified in the PHP configuration.

Fatal error: Call to undefined function imap_open() in PHP

This error message indicates that the PHP script you are running is trying to use the imap_open() function, but it is not defined or not enabled in your PHP configuration.

Fatal error: Call to undefined function mysqli_connect()

The "Fatal error: Call to undefined function mysqli_connect()" error in PHP typically occurs when the MySQLi extension is not enabled or properly configured in your PHP environment.

Fatal error: Call to undefined function: ldap_connect()

This error message is indicating that the PHP function ldap_connect() is not defined or not available.

Fatal error: Class 'Illuminate\Foundation\Application' not found

This error message indicates that the Laravel framework is unable to find the Application class from the Illuminate\Foundation namespace.

Fatal error: Class 'NumberFormatter' not found

This error message is indicating that the PHP script is trying to use a class called "NumberFormatter" but it cannot be found.

file upload php $_FILES undefined index error

The error "Undefined index: (name of the file input)" in PHP usually occurs when the form that is used to upload the file is not properly configured.

file_get_contents behind a proxy?

The file_get_contents function in PHP can be used to retrieve the contents of a file from a remote server.

file_get_contents() Breaks Up UTF-8 Characters

The file_get_contents() function in PHP is used to read the contents of a file into a string.

file_put_contents and a new line help

file_put_contents is a PHP function that writes a string to a file.

Find last iteration of foreach loop in laravel blade

In Laravel Blade, you can use the @forelse loop to check if the last iteration of a loop has been reached.