|
-
Jan 14th, 2003, 11:13 PM
#1
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?
-
Jan 15th, 2003, 07:32 AM
#2
New Member
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.
-
Jan 15th, 2003, 07:42 AM
#3
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.
-
Jan 15th, 2003, 07:45 AM
#4
New Member
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()
-
Jan 15th, 2003, 07:57 AM
#5
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|