★ wanayoo — archive 1999 http://www.php.net/manual/function.die.phpNouvelle recherche | Portail wanayoo

PHP Home Page

Manual Table of Contents
Up to Misc.
Quick Reference
Misc.
* connection_aborted
* connection_status
* connection_timeout
* define
* defined
* die
* eval
* exit
* func_get_arg
* func_get_args
* func_num_args
* function_exists
* get_browser
* ignore_user_abort
* iptcparse
* leak
* pack
* register_shutdown_function
* serialize
* sleep
* uniqid
* unpack
* unserialize
* usleep
Manual: die
View the source code for this pageSearch the site



Previous page
 defined
eval 
Next page


die

die --  Output a message and terminate the current script

Description

void die (string message)

This language construct outputs a message and terminates parsing of the script. It does not return anything.

Example 1. die example

  1 
  2 <?php
  3 $filename = '/path/to/data-file';
  4 $file = fopen ($filename, 'r')
  5     or die("unable to open file ($filename)");
  6 ?>
  7       

See also exit().


User Contributed Notes: die


bparsons@ou.edu
23-Apr-2000 01:14
Make sure to put your string to give to die in parentheses--at least in PHP4 RC1. ie ... or die ("[Some string]");


apadhi@hotmail.com
13-May-2000 09:43
HI Folks, with die you can also call a function. eg. : mysql_query("xxxx") or die mysql_error(); You can use your own function like : function errmailer() { global x; $err=mysql_error(); echo "There is an error"; mail("a@b.com","error message \n $x","$err","from : c@d.com"); } and then you can give a command at a desired place like mysql_query("xxxx") or die errmailer(); This can be useful quite a lot for debugging errors when they happen through unknown users and through unkbown events trigerred by the user unknowingly


apadhi@hotmail.com
13-May-2000 09:43
HI Folks, with die you can also call a function.
eg. :
mysql_query("xxxx") or die mysql_error();
You can use your own function like :

function errmailer()
{
global x;
$err=mysql_error();
echo "There is an error";
mail("a@b.com","error message \n $x","$err","from : c@d.com");
}

and then you can give a command at a desired place like

mysql_query("xxxx") or die errmailer();

This can be useful quite a lot for debugging errors when they happen through unknown users and through unkbown events trigerred by the user unknowingly



 About Notes


Previous page
 defined
eval 
Next page



Site Statistics


Who's responsible for this?
Top of this page

Site
Hosting:



Located in
United States
Elements of this website are subject to copyright.
Questions about installing or using PHP should be directed to one of the mailing lists.
Only questions about the website should be directed to webmaster@php.net.