I want to do something like this for simplifying logging operations. Any idea what I should put in for ?[1]? and ?[2]??
function log_var($var) {
$line = ?[1]?;
$var_name = ?[2]?;
$line--;
$filepath = 'log-' . date('Y-m-d'). '.txt';
$message = "$line, $var_name = $var\n";
$fp = fopen($filepath, "a");
fwrite($fp, $message);
fclose($fp);
@chmod($filepath, 0666);
return TRUE;
}
This how I'd use the function in code (numbers are assumed to be line numbers in actual code):
23 $a = 'hello';
24 log_var($a);
25 $b = 'bye';
26 log_var($b);
And this is what I want to be written to the log file:
23, a = hello
25, b = bye