writeFile() (tick_24Pro, cross_24Std, cross_24Lite)

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 it to work.

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 (new v11.9942)

2 - no error, but the variable doesn't exist (or is undefined) so nothing was written (new v11.9942)

1 - no error, but did not do anything because this function is not supported in the current edition

0 - normal operation (should have succeeded)

-1 - could not open $filename


1 - append to the end of $filename instead of overwriting it

2 - do not add any line termination characters (New v14.0210)

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) (New v14.9910)

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. (New v14.0210)

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 in the professional and enterprise editions.

Functionality change in CSE HTML Validator v11.9942 and later: $var represents a literal string or a variable reference; do not use a literal string like "varname" to represent a variable, instead use $varname