Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to use fgets() function in PHP?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 245
    Comment on it

    Hi Reader's,
    Welcome to FindNerd, today we are going to discuss what is  the  use of  fgets in PHP ? 

    If you want a function that returns a line from an open file and after a specific length(the length that is specified by you) it should stop returning on a new line for that  you can use fgets() function.

     

    syntax of fgets() :

    fgets(file,length)

     

    There are two main parameter of fgets() function 

    1- file:-this is a required parameter and specifies the file to read
    2- length:-this is a optional parameter.

     

    you can see below example
     

    <?php
    
      //here define a file variable and call file.txt page and use fopen()
      $file = fopen("file.txt","r");
      //here call fgets() 
      echo fgets($file);
      //here call fclose() function
      fclose($file);
    
    ?>
    

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: