[pmwiki-users] Problem with $FmtPV;
Patrick R. Michaud
pmichaud at pobox.com
Tue May 22 11:04:06 CDT 2007
On Tue, May 22, 2007 at 11:15:33AM -0400, Ben Wilson wrote:
> On 5/22/07, Stirling Westrup <sti at pooq.com> wrote:
> > Ben Wilson wrote:
> > > I am setting $FmtPV with the following value: '2007W19'; This is how I
> > > set it, outside of any function, but in a recipe.
> > >
> > > $FmtPV['$YearWeek'] = '2007W19';
> >
> > This won't work. The contents of $FmtPV are run through eval. That
> > means it has to be a valid PHP expression. 2007W19 isn't one.
>
> Thanks. But then why does it not fail otherwise?
In the case where you had
$FmtPV['$YearWeek'] = 'a2007W19';
when PHP evaluates "a2007W19" it sees it as a "bareword string"
and automatically treats it as a string. For example, in PHP I
can write:
$x = a2007W19;
PHP automaticaly treats the bareword string as though I had written:
$x = 'a2007W19';
But with
$FmtPV['$YearWeek'] = '2007W19';
$FmtPV['$YearWeek'] = 'Test-2007W19';
PHP ends up evaluating the constants as though we had written
$x = 2007W19; # $x = 2007 'W19';
$x = Test-2007W19; # $x = 'Test' - 2007 'W19'
and gets confused at the W19 part, because it sees a bareword
string where it was expecting an operator of some sort.
Pm
More information about the pmwiki-users
mailing list