[pmwiki-devel] ZAPcart configurability [was: Stumped on string insertions...]

The Editor editor at fast.st
Mon Apr 9 06:27:45 CDT 2007


On 4/8/07, J. Meijer <commentgg at hotmail.com> wrote:
>
> Hi Dan,
>
> Your intuition is apparently bugging you, like this: there must be a way to
> invoke "string $var substitutions" on a string-variable, not just on literal
> strings. Well the closest thing (AFAIK) is strtr()
> (http://www.php.net/manual/en/function.strtr.php).

Yes it was bugging me!  :)  Figured there ought be someway to do it...

> However, since you're performance conscious, I did some experimenting just
> to see how various alternatives would fare. See the code below.
>
> It turns out that str_replace outruns everything by far. Strtr() is 4 times
> slower(!) and using eval() to invoke "string $var substitutions" is 7..8x
> slower.

Great!  Appreciate the tip.  I got around to tinkering some with it,
and this approach worked just fine after all.  Makes things quite
nice.

> Patrick at some point probably did the same profiling. A similar problem
> occurs in FmtPageName(), he uses:
>
>     $fmt =
> str_replace(array_keys($g),array_values($g),$fmt);
>
> Which is also your best bet.
>
> Keep that mindstorm going!


Thanks again for the help.  Almost have the ZAPcart recipe done.  It
will be a big improvement over the earlier release in terms of
flexibility and configurability. Your tip helped a bunch!

Cheers,
Dan

PS.  I do have one other question I can't seem to get working.  When I
submit a form using ZAP, shouldn't the values in the form be
retrievable to the next page using $_REQUEST or $_POST in a markup on
the next page?  Or do I have to do something different?  ZAP doesn't
really do anything to the post values and then reloads the page using
either HandleBrowse or Redirect...  Doesn't seem to work either way...



More information about the pmwiki-devel mailing list