How-to articles, tricks, and solutions about PHP

Changing a global variable from inside a function PHP

In PHP, global variables can be accessed and modified from within functions using the global keyword.

Changing permissions via chmod at runtime errors with "Operation not permitted"

It sounds like you are trying to use the chmod command to change the permissions on a file, but you are encountering an error that says "Operation not permitted".

Check if $_POST exists

To check if the $_POST superglobal variable exists in PHP, you can use the isset() function.

Check if all values in array are the same

In PHP, you can use the array_unique function to check if all values in an array are the same.

Check if number is decimal

In PHP, you can use the is_float() function to check if a variable is a decimal number.

Check if xdebug is working

To check if Xdebug is working, you can try the following steps:

CHECK PHP SESSION - ISSET($SESSION - IS NOT WORKING

It sounds like you are having an issue with the isset() function in PHP not working properly when checking for a session variable.

Checking for an empty result (PHP, PDO, and MySQL)

In PHP, you can use the PDO (PHP Data Objects) extension to interact with a MySQL database.

Checking if a variable is an integer in PHP

In PHP, you can use the is_int() function to check if a variable is an integer.

Checking if date is weekend PHP

To check if a date is a weekend in PHP, you can use the date function to get the day of the week for a given date and then check if it is either 0 (Sunday) or 6 (Saturday).

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.

Clearing content of text file using php

To clear the contents of a text file using PHP, you can use the file_put_contents() function.

Codeigniter $this->db->get(), how do I return values for a specific row?

The $this->db->get() function in CodeIgniter is used to retrieve data from a database table.

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.

Codeigniter Rename file on upload

In CodeIgniter, you can rename a file on upload by using the do_upload() method of the Upload class.

Codeigniter: fatal error call to undefined function mysqli_init()

Here's an example of how the error might appear in a Codeigniter application:

Codeigniter's `where` and `or_where`

In CodeIgniter, the where method on the database class is used to add a WHERE clause to your query.

Commands out of sync; you can't run this command now

The "Commands out of sync; you can't run this command now" error in PHP usually occurs when you have called a MySQL function in an incorrect order.

Compiling php with curl, where is curl installed?

The location of the curl installation depends on the operating system and the method used to install it.

Composer loading from cache

When you use the Composer package manager to install PHP packages, it stores a local cache of the packages that you have installed.

Composer require local package

To require a local package in Composer, you can use the "path" option in the "require" section of your project's composer.json file.

Composer: Command Not Found

It looks like you are trying to use the composer command, but it is not recognized by your terminal.

Composer: file_put_contents(./composer.json): failed to open stream: Permission denied

This error message is indicating that the script is trying to write to the file "composer.json" in the current directory (indicated by "./"), but it doesn't have the necessary permissions to do so.

Composer: remove a package, clean up dependencies, don't update other packages

To remove a package with Composer, you can use the command composer remove [package-name].