die是终止程序。也就是程序执行到此,以后的程序就不会再执行了。例子$file="test.txt";
if(!file_exists($file)){//如果文件不存在
   die("您想操作的文件不存在");
}
echo filesize($file);//如果存在的话,执行这句,否则不执行

解决方案 »

  1.   

    die跟exit一样的用法。手册上说的
    die -- Alias of exit()exit
    (PHP 3, PHP 4 )exit -- Output a message and terminate the current script
    Description
    void exit ( [string status])void exit ( int status)
    注: This is not a real function, but a language construct. 注: PHP version >= 4.2.0 does NOT print the status if it is an integer. The exit() function terminates execution of the script. It prints status just before exiting. If status is an integer, that value will also be used as the exit status. Exit statuses should be in the range 1 to 254, the exit status 255 is reserved by PHP and shall not be used. 例子 1. exit() example<?php$filename = '/path/to/data-file';
    $file = fopen ($filename, 'r')
        or exit("unable to open file ($filename)");?>
     
     
    注: The die() function is an alias for exit(). 
      

  2.   

    既然说是The die() function is an alias for exit(). 就说明没有分别了