All pastes #290861 Raw Edit

Unnamed

public text v1 · immutable
#290861 ·published 2006-12-24 13:04 UTC
rendered paste body
function write($fileloc, $content, $type) {
	if (empty($fileloc)) {
		return false;
	}
	if (empty($content)) {
		return false;
	}
	if (empty($type)) {
		return false;
	}
	if (is_writable($fileloc)) {
		if (!$handle = fopen($fileloc, $type)) {
			return false;
		}
		if (fwrite($handle, $content) === FALSE) {
			return false;
		}
		fclose($handle);
		echo "Wrote to $fileloc with type $type\n";
	}
	else {
		return false;
	}
}