How-to articles, tricks, and solutions about PHP
PHP is a programming language that is often used to build web applications.
To return only alpha-numeric characters from a string in PHP, you can use the preg_replace function with a regular expression pattern that matches any non-alphanumeric character.
The set_magic_quotes_runtime function has been deprecated since PHP 5.3 and removed in PHP 7.0.
In PHP, you can use the $array[$key] syntax to get the value stored at a particular key in an array.
To validate a file size in Laravel, you can use the size rule in your request validation.
To get a single value from a MySQL query in Laravel, you can use the value method on a query builder instance.
You can check if the $_GET array is empty by using the empty() function.
To convert a multidimensional array into a single array in PHP, you can use the array_merge() function.
To work with User Account Control (UAC) when installing XAMPP, you can try the following steps:
To use the file_get_contents function to retrieve the contents of an external URL in PHP, you will first need to ensure that the allow_url_fopen directive is enabled in your php.ini file.
To store the file name in a database along with other information while uploading an image to a server using PHP, you can follow these steps:
Error 1146: Table 'table_name' doesn't exist
In PHP, the "|" and "||" operators are both bitwise and logical operators.
The __get and __set magic methods in PHP are used to intercept calls to get or set the value of inaccessible properties of an object.
In CodeIgniter, the where method on the database class is used to add a WHERE clause to your query.
To minify HTML output in PHP, you can use the following steps:
To export a MySQL database using PHP, you can use the mysqldump command-line utility or the mysqli extension.
You can use the array_column function to get an array of specific keys from a multidimensional array.
To set the value of a POST variable in PHP, you can use the following code:
To get the content of a webpage using cURL, you can use the following command:
To set a cookie in Laravel, you can use the Cookie facade.
To save a PHP array to a MySQL database, you can use the serialize() function to convert the array into a string, and then use an INSERT or UPDATE statement to save the string into a TEXT or LONGTEXT field in the database.
To install all of the required PHP extensions for Laravel, you will need to install the following PHP extensions on your server:
Here is some sample PHP code that calculates a person's age based on their date of birth: