|
-
Feb 21st, 2002, 03:53 PM
#1
Thread Starter
Hyperactive Member
Ignore error and continue
in this example it will open 1.txt , 2.txt and 3.txt
for ($i = 1; $i <= 3; $i++)
{
$FILE=fopen("$i.txt","r");
$Find=fgets($FILE,4096);
fclose($FILE);
}
the problem:
1.txt file is not found now so it give me error message. I want to ignore this error message and continue the program without give me any error message . how can I do that ?
-
Feb 21st, 2002, 09:43 PM
#2
Member
if you want to turn off error msgs completely for this script, write the following before the code:
error_reporting(0);
inside a PHP block of course!
if youjust want to bypass errors from certain functions, precede those fns with '@' like:
@fopen(whatever....);
HTH.
-
Feb 23rd, 2002, 10:14 AM
#3
Member
or you can say
if(file_exists("$i.txt")) {
fopen...
}
or just use @
I swear you guys rip on me 13 or 14 more times, i'm outta here...
-
Feb 23rd, 2002, 02:53 PM
#4
Thread Starter
Hyperactive Member
Thanks
Thank you Very much hardcoder & Howard Stern
-
Feb 25th, 2002, 03:27 PM
#5
or you can start i as 2
for ($i = 2; $i <= 3; $i++)
{
$FILE=fopen("$i.txt","r");
$Find=fgets($FILE,4096);
fclose($FILE);
}
but will only stop the error for 1.txt.
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
|