int errorcode writeFile(string $filename, var $var[, int $flags]);
This function may pose a security risk and a risk for accidental damage such as data loss; use it carefully. Also, enable potentially destructive functions in the Config Files Options Page for this function to work (unless flag 8 or 16 is used).
•Writes the contents of $var to $filename and returns errorcode. This function is useful for logging purposes. If $var is an array, then writes the entire array with each element (converted to a string) on a new line.
•errorcode (return value)
•3 - no error, but the function is disabled because potentially destructive functions are not enabled (only if flag 8 or 16 is not used)
•2 - no error, but the variable doesn't exist (or is undefined) so nothing was written
•1 - no error, but did not do anything because this function is not supported by the current edition
•0 - normal operation (should have succeeded)
•-1 - could not open $filename
•$flags
•1 - append to the end of $filename instead of overwriting it; ignored if flag 8 or 16 is used (an empty string is recommended if using flag 8 or 16)
•2 - do not add any line termination characters
•4 - include a UTF-8 signature (byte-order mark (BOM)) at the beginning of the file (if appending with flag 1 then will write the signature only if the file doesn't already exist); ignored if flag 8 or 16 is used
•8 - ignore $filename and write to stdout; >output.txt or >>output.txt (append) can be used on the command line to redirect stdout to a file (New v22.01)
•16 - ignore $filename and write to stderr; must not use flag 8 at the same time; 2>output.txt or 2>>output.txt (append) can be used on the command line to redirect stderr to a file (New v22.01)
•32 - prepend a date and time stamp like "2022-02-21 15:48:57: " (works with flag 8 and 16) (New v22.01)
•It is most efficient to use this function in the end validation program to write a multi-line array (created using addValue()) to a file instead of writing each line to a file with multiple calls to writeFile()
•Uses UTF-8 encoding with no signature (unless flag 4 is used to include a UTF-8 signature).
•A new line character (ASCII code 10) is used to terminate each line that is written to the file (unless flag 2 is used).
•This function is only supported by the Pro and Enterprise editions.
•$var represents a literal string to write to the file or a variable reference; do not use a literal string like "varname" to represent a variable, instead use $varname
•If using flag 8 or 16 to write to stdout or stderr then potentially destructive functions do not need to be enabled and $filename is ignored.