Questions tagged [die]

die is a function in several languages. In Perl, die raises an exception or aborts the program. In PHP, die exits the program. In jQuery, the die method removes an event handler.

die is a function to terminate the calling program and display an error message in several languages.

In , the built-in function die raises an exception. If this exception is not caught, the argument to die is printed on STDERR and the program is terminated.

In , the built-in function die is a synonym of exit; it terminates the program.

In , the .die() method (deprecated: 1.7, removed: 1.9) removes event handlers that were previously attached with .live() (see ).

228 questions
764
votes
17 answers

What are the differences in die() and exit() in PHP?

What are the differences between die() and exit() functions in PHP? I think both have the same functionality, but I doubt there is something different in both... what is it?
coderex
  • 27,225
  • 45
  • 116
  • 170
237
votes
25 answers

How to terminate the script in JavaScript?

How can I exit the JavaScript script much like PHP's exit or die? I know it's not the best programming practice but I need to.
Nir
  • 24,619
  • 25
  • 81
  • 117
35
votes
3 answers

How can I get around a 'die' call in a Perl library I can't modify?

Yes, the problem is with a library I'm using, and no, I cannot modify it. I need a workaround. Basically, I'm dealing with a badly written Perl library, that exits with 'die' when a certain error condition is encountered reading a file. I call this…
Ed Hyer
  • 1,385
  • 2
  • 13
  • 19
34
votes
8 answers

Can I catch exit() and die() messages?

I'd like to be able to catch die() and exit() messages. Is this possible? I'm hoping for something similar to set_error_handler and set_exception_handler. I've looked at register_shutdown_function() but it seems to contain no context for the…
Beau Simensen
  • 4,558
  • 3
  • 38
  • 55
31
votes
1 answer

Php: when to use pthread

I don't know much about using threads but I looked into pthreads for php and it seems very interesting and easy, or easier than I thought... I searched for examples and looked through the documentation but I couldn't find any real-world examples of…
joschua011
  • 4,157
  • 4
  • 20
  • 25
20
votes
6 answers

PHP: Utilizing exit(); or die(); after header("Location: ");

I have a user login/registration system that simply uses // execute queries, set cookies, etc. here header("Location: " . getenv("HTTP_REFERER")); I recently read a post about exit(); and die(); and had no idea that I was supposed to be using…
Aaron
  • 1,956
  • 5
  • 34
  • 56
15
votes
5 answers

Perl built in exit and print in one command

I know I can die but that prints out the script name and line number. I like to do things like die 'error' if $problem; Is there a way to do that without printing line number stuff? It would be nice not to have to use braces if($problem){print…
700 Software
  • 85,281
  • 83
  • 234
  • 341
15
votes
7 answers

Perl: After a successful system call, "or die" command still ends script

I am using the following line to make a simple system call which works: system ("mkdir -p Purged") or die "Failed to mkdir." ; Executing the script does make the system call and I can find a directory called Purged, but the error message is still…
FintleWoodle
  • 157
  • 1
  • 1
  • 7
15
votes
5 answers

Difference between 'die' and 'exit'

Possible Duplicate: what are the differences in die() and exit() in PHP? I am totally confused in the difference of die and exit. Most programmers use die like this. $link = mysql_connect('localhost', 'mysql_user', 'mysql_password'); //don't see…
Yogesh Suthar
  • 30,424
  • 18
  • 72
  • 100
14
votes
1 answer

PHP: Modern version of "or die();" for error handling

When I first started learning PHP, I would write query statements similar to the one here: mysql_query("SELECT * FROM `table`") or die(mysql_error()); What is the best, present-day way, to achieve the same effect as the above? To my understanding,…
Aaron
  • 1,956
  • 5
  • 34
  • 56
14
votes
2 answers

Forking subprocesses in Perl unit tests stops prove; Test::Harness exiting

I have been trying to use the Perl utility/module "prove" as a test harness for some unit tests. The unit tests are a little more "system" than "unit" as I need to fork off some background processes as part of the test, Using the following... sub…
Vagnerr
  • 2,977
  • 3
  • 33
  • 46
13
votes
2 answers

How can I make Perl die if a warning is generated?

I would like my script perl to die whenever a warning is generated, including warnings which are generated by used packages. For example, this should die: use strict; use warnings; use Statistics::Descriptive; my @data = ( 8, 9, 10, "bbb" ); my…
David B
  • 29,258
  • 50
  • 133
  • 186
13
votes
3 answers

PHP: What is the difference between exit(), die() and return; within "self" and included files?

Am am still on a PHP learning curb. When terminating a script, what is the difference between exit(), die(); and return;?: within the same file (Single script file) Within the child of an include Within the parent of an include
Omar
  • 11,783
  • 21
  • 84
  • 114
11
votes
3 answers

jQuery: Binding and Unbinding Live Click Events

So there are two constraints to my question: I must use an external function call in my click event, and I must use a live click event, rather binding a typical click event. So my problem is that I'm trying to unbind a click event after it…
Matt
  • 23,363
  • 39
  • 111
  • 152
10
votes
5 answers

what does PHP die() return

in PHP Does die() gives anything in return when we use it?
developer
  • 2,042
  • 10
  • 40
  • 59
1
2 3
15 16