How-to articles, tricks, and solutions about PHP
One best practice for implementing a multi-language website in PHP is to use a language detection library such as Text-Language-Detect.
A common practice for generating a random token for a "forgot password" feature in PHP is to use the built-in functions random_bytes and bin2hex.
There are a few ways you can test protected methods using PHPUnit:
One solution to protect PHP code without encryption is to use code obfuscation.
To check if a MySQL query returned any results, you can use the mysqli_num_rows function.
To get specific attributes from a Laravel Collection, you can use the pluck method.
When documenting an array option in PHPDoc, you can use the @var tag followed by the type array and a short description of the option.
The best way to give a variable a default value in PHP is to use the ternary operator ?:.
The best way to store passwords in a MySQL database is to use a one-way hashing algorithm, such as bcrypt or scrypt, to hash the password before storing it in the database.
In PHP, the isset() function is used to check if a variable has been set, meaning that it has been declared and is not equal to NULL.
One way to block direct access to a file over HTTP but allow PHP script access is to use a .htaccess file in the same directory as the file.
To break out of a loop in PHP, you can use the break statement.
Here is some sample PHP code that calculates a person's age based on their date of birth:
To calculate the difference between two dates using Carbon and Blade, you can use the following steps:
The error message "Call to undefined function curl_init()" typically indicates that the cURL extension for PHP is not installed or is not enabled.
To call a PHP function using an onclick event, you will need to use a little bit of JavaScript.
In PHP, you can call a function within the same controller by simply calling the function name followed by parentheses.
Yes, a class in PHP can extend another class and implement one or more interfaces at the same time.
Yes, you can pass an array as a parameter to a function in PHP.
In PHP, if you want to access a global variable inside a function, you need to use the "global" keyword.
There are several possible reasons why cURL is returning a 0 length response when trying to connect to an HTTPS site.
In PHP, this error message typically occurs when a function or method that is expected to return a value is being used in a context where a value cannot be written.
There could be several reasons why you are unable to write image data to a path in Laravel using the Intervention library.
To change the global path for Composer on Windows, you will need to update the system environment variables.
In Laravel or Lumen, you can set the timezone for your application by setting the timezone option in your config/app.php configuration file.