Learn how to use the is_executable(), is_readable(), is_writable(), fileperms(), and chmod() functions to determine whether your PHP script has permission to execute, read or write a particular file.
Category: PHP
PHP is a scripting language that’s usually embedded or combined with HTML and has many excellent libraries that provide fast, customized access to DBMSs.
How to check the type of a file. For example, check whether the provided file name is a directory, a file, or a symbolic link.
Parsing INI Strings and Files
Let’s write the PHP configuration information, such as the database host and user credentials, in an INI file. Then use the parse_ini_file() function to parse this information in your web application.
Reading and Writing CSV Files
CSV is a file format and stands for “comma-separated values”. In this tutorial, we use the fgetcsv() function to read a CSV file and fputcsv() function to write CSV records into a file.
Writing or Appending to Files
Writing to files is as easy as reading from them. In this tutorial, we’ll use the file_put_contents() and fwrite() functions to write and append to files. You’ll also learn how to lock files to avoid trouble when one process writes while the other one reads.
Reading files by line or by character
In this tutorial, you will learn how to parse large files, keeping the system’s memory safe. We will use the PHP functions (fgets, fgetc, and fread) that can read chunks of the file content at a time.
Opening and Closing Files
fopen() is the function to open a file on disk as a resource. This function gives you access to any file and its contents. When you open a file, you can open it for several purposes, for example, reading, writing, and appending (adding information to the end of the file).
Reading a File into a String or Array
To read data from a file, PHP offers several possibilities. Probably the easiest way is to read it all at once with file_get_contents() function and then output it to the user or read it line by line with file() function.
Learn how to force download files in PHP and how to generate a TXT, CSV, or JSON file on the fly from a string and send it to the browser.
AJAX Multiple Files Upload
In this tutorial, we’ll create an AJAX form that can upload and validate multiple files.