filehandling - some help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

i know that, but i want to know if there is some way to just quit the function and jump to the error handling part. like "On Error Goto errhandler" in VB
Draco_03
Forum Regular
Posts: 577
Joined: Fri Aug 15, 2003 12:25 pm
Location: Montreal, Canada

Post by Draco_03 »

Bech100 wrote:what about this

Code: Select all

$fp = @fopen ($filename, "r") or die($error_handler("fopen1")); //Open file for reading
it didn't work ??
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

anyone?
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

so there aren't any command that exits the current function?
something like this:

Code: Select all

@file ('test.txt') or exit($error = "file");
please, i really need one!
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post by DuFF »

Why not just do something like this?

Code: Select all

<?php
$filename = "test.txt";
if(!$fp = @fopen ($filename, "r"))
  {
  echo "fopen failed!";
  // call a function or anything else you want to do here
  }
else
  {
  echo "fopen was successful!";
  // call a function or anything else you want to do here
  }
?>
Post Reply