Page 1 of 1

Jump to another part of the php-file

Posted: Sat Dec 20, 2003 5:11 pm
by vigge89
Is there any way to jump to another part in the PHP-file?
like in Visual Basic, u can have this code:

Code: Select all

On error goto errhandler 'On error goto errhandler
goto part 'Goto part

Exit Sub

part:
'This is were something will be done
Exit sub

errhandler:
msgbox "Error.....bla bla bla"
Exit Sub
Is this possible in PHP?
becuase i've created a function that opens a file, reads from it, and the closes it etc.

But if there is an error;

Code: Select all

<?php
@fwrite ($fp, $newcontent) or [*inputsomething here*];
?>
It should goto another part of the script.

Posted: Sat Dec 20, 2003 5:47 pm
by m3mn0n

Code: Select all

<?php
function error ($msg)
{
   echo $msg;
      exit;
}

// ...
// code
// ...

if (fwrite ($fp, $newcontent))
{
  // exec more code
} else {
  error("Doh!");
}
?>

Posted: Sat Dec 20, 2003 6:57 pm
by vigge89
oh, never thought of that ;)
i'll try it out tomorrow :D