Contents /
Previous /
Next
Miscellaneous Functions
Exit and Die
void exit ( [string status]) or void exit ( int status):
Is a language construct.
It outputs a message (status) and terminates the current script.
If status is an integer, that value will also be used as the exit
status (should be in the range 1 to 254, 255 is reserved by PHP).
Example:
$filename = '/path/to/data-file';
$file = fopen ($filename, 'r')
or exit("unable to open file ($filename)");
?>
The die() function is an alias of exit().
Syntax Highlighting
mixed highlight_file ( string filename [, bool return]):
prints out a syntax highlighted version
of the code contained in filename using the colors defined in the
built-in syntax highlighter for PHP.
If the parameter "return" is TRUE,
the highlighted code will be returned as a string instead of printing it
out. If the second parameter is not set to TRUE then highlight_file()
will return TRUE on success, FALSE on failure.
Example
(display a colorized version of a script located in "script.php"):
$php_file = "objects.php";
echo "Source of: $php_file
\n
\n";
highlight_file($php_file);
?>
mixed highlight_string ( string str [, bool return]):
Outputs a syntax highlighted version
of str similar to highlight_file().
Sleep
void sleep ( int seconds):
Delays program execution for the given number of seconds.
void usleep ( int micro_seconds):
Delay execution in microseconds,
void set_time_limit ( int seconds):
Set the number of seconds a script is allowed to run. If this is
reached, the script returns a fatal error. The default limit is 30
seconds or zero, meaning no time limit is imposed
(set max_execution_time in php.ini).
set_time_limit() has no effect in safe mode.