Php create txt file in directory

View Discussion

Improve Article

Save Article

  • Read
  • Discuss
  • View Discussion

    Improve Article

    Save Article

    We can easily create a folder in PHP, but before that, you have to check if the folder or directory already exists or not. So In this article, you will learn both to Check and Create a folder or directory in PHP. 

    Methods:

    1. file_exists[]: It is an inbuilt function that is used to check whether a file or directory exists or not.
    2. is_dir[]: It is also used to check whether a file or directory exists or not.
    3. mkdir[] :  This function creates a directory.

    Method 1: Using file_exists[] function: The file_exists[] function is used to check whether a file or directory exists or not.

    Syntax:

    file_exists[ $path ]

    Parameters: The file_exists[] function in PHP accepts only one parameter $path. It specifies the path of the file or directory you want to check.

    Return Value: It returns True on success and false on failure. 

    Example:

    PHP

    Bài mới nhất

    Chủ Đề