[pmwiki-devel] strange FmtPV behavior...

Patrick R. Michaud pmichaud at pobox.com
Thu Apr 5 09:07:01 CDT 2007


On Thu, Apr 05, 2007 at 09:54:41AM -0400, The Editor wrote:
> Any explanation why the following give different results?
> 
> #1)
> $FmtPV['$orderpage'] = 'ZAPorderpage()';
> function ZAPorderpage() {
> 	$OrderGroup = ZAPconfig('Order', 'Order');
> 	$OrderName = strftime("%Y%j", time()) . "-" .
> strtoupper(substr(session_id(), 0, 16));
> 	return $OrderGroup . "." . $OrderName;
> 	}
> 
> #2)
> $FmtPV['$orderpage'] = "'" . ZAPconfig('Order', 'Order') . "." .
> strftime("%Y%j", time()) . "-" . strtoupper(substr(session_id(), 0,
> 16)) . "'";

The first one computes the value when the $orderpage page variable
is being evaluated -- ZAPConfig() isn't called until someone requests
the value of {$orderpage} .

The second one computes the value at the time the $FmtPV['$orderpage']
is being set.  In other words, it immediately calls ZAPConfig()
and uses the results as the constant output value.

So, the reason why they are different is that ZAPConfig() returns
different values depending on if it's being called immediately
or later in the program.

Note that session_id() may return different values as well, depending
on whether the session is being opened before or after setting
$FmtPV['$orderpage'].

Pm



More information about the pmwiki-devel mailing list