Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Functions | Variables
mailout-debugger.php File Reference

Print an error to STDOUT and exit with a non-zero code. More...

Functions

 mdie ($msg='', $errorcode=1)
 

Variables

 $fh
 
 $stdin = fopen('php://stdin', 'r')
 
if(!file_exists(__DIR__.'/mailout-debugger.enable')) $tmpdir =sys_get_temp_dir()
 
if(isset( $_SERVER[ 'REMOTE_ADDR'])) if(isset($_ENV['TMPDIR']) &&is_dir($_ENV['TMPDIR'])) $tmpfile = $tmpdir . '/moodle-mailout.log'
 

Detailed Description

Print an error to STDOUT and exit with a non-zero code.

For commandline scripts. Default errorcode is 1.

Very useful for perl-like error-handling:

do_something() or mdie("Something went wrong");

Parameters
string$msgError message
integer$errorcodeError code to emit

Variable Documentation

◆ $fh

$fh
Initial value:
= fopen($tmpfile, 'a+', false)
or mdie("Error openning $tmpfile on append\n")
mdie($msg='', $errorcode=1)
Print an error to STDOUT and exit with a non-zero code.
Definition: weblib.php:2781