Results 1 to 5 of 5

Thread: File handling questions

  1. #1

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Question File handling questions

    1. If I use

    PHP Code:
    $fileget file("zzz.txt"); 
    Do I need to close the file after I have used it? If so, how can I close it?



    2. Suppose there is a file named telephone.php. I wish to include only its 3rd and 4th lines. THe 3rd and 4th lines happen to contain PHP code by the way, and I would like that PHP code to be executed. How can I do this?

  2. #2
    New Member
    Join Date
    Jan 2003
    Posts
    11
    1.) You don't need to close it.

    2.) erm.. the 3rd and 4th lines... You could get them using file(), but I don't know how you could get them to execute.

    Btw. file() returns an array of lines, readfile() returns the file as one big string.

  3. #3

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Thanks.

    I figured out how to get the lines 3 and 4...


    PHP Code:
    $filelines sizeof($fileget);
    if (
    $filelines 4){
    echo 
    $fileget[3];
    echo 
    $fileget[4];
    }

    //$fileget was used earlier as $fileget=file("zzz.php"); for example 

    But that won't execute the PHP.

    Welcome back, btw.

  4. #4
    New Member
    Join Date
    Jan 2003
    Posts
    11
    Originally posted by mendhak
    But that won't execute the PHP.

    Welcome back, btw.
    Thanks

    I think I might have got it...

    Write the lines to a temporary .php file, and then use include() or virtual()

  5. #5

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Good idea. I'll try it out.

    Tx.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width