The file extension is very useful for validation and upload. You can easily get extension from the file name or file location using PHP. The pathinfo() function provides the easiest way to get file information in PHP. Also, you can use substr() and strrchr() function to get file extension in PHP.
PHP $_SERVER variable provides an easy way to get user IP address. The simplest way to get the visitor IP address is using the REMOTE_ADDR in PHP. Use $_SERVER[‘REMOTE_ADDR’] to get IP address of the user in PHP. Alternatively, use HTTP_X_FORWARDED_FOR to get real IP address of user in PHP.
Code optimization can reduce the execution time of the script. Using the looping statements, you can get an array of a specific key from the multidimensional array. But the same work can be done in a single line of code by array_column() function in PHP.
PHP array_filter() function filters elements of an array by a callback function and it can be used for many purposes. The array_filter() function provides a short and simple way to filter multidimensional array by key and value. Use array_filter() to filter values from multidimensional array similar to SQL LIKE using array_filter() function in PHP.
By default, PHP allows uploading maximum 2 MB file on the server. But you can change the maximum size of file upload as per your requirement. Using the PHP configuration file (php.ini), you can increase or decrease the file upload size in PHP.
The php.ini file is a default configuration file that read on PHP starts up. The PHP settings and configuration can be modified by the php.ini file. If you want to change the PHP settings on Ubuntu, php.ini file is an easy and most effective way to do it. Follow the steps to modify the PHP configuration file (php.ini) using the command line on Ubuntu.
Are you want to calculate the difference between two dates in PHP? There are a simple way to get the number of days between two dates in PHP. Use date_create() and date_diff() function to get number of days between two dates in PHP.
The GD library is required to create and manipulate images in PHP. You need to enable GD library support for working with image functions in PHP. Here we’ll show you how to install GD library in PHP on Windows server. Follow the step-by-step instruction to install PHP GD library in XAMPP or WAMP server.
PHP array_filter() function filters elements of an array using a callback function and returns the filtered array. Here we’ll provide a short PHP code snippets to filter elements of an array that contain a specific value. It will help you to filter an array based on particular condition.
Join our 75,000+ subscribers and get the latest tutorials and resources, straight to your inbox.