[pmwiki-devel] String confusion

Patrick R. Michaud pmichaud at pobox.com
Thu Nov 15 11:56:07 CST 2007


On Thu, Nov 15, 2007 at 10:42:15AM -0700, Robert Clark wrote:
> I'm missing some basic understanding here, and I'm hoping someone can
> help me out (any comments/criticism are appreciated).
> 
> Here's a fragment of some code from a recipe I'm working on:
> 
> Markup('node',    $when, '/\\(:node (.*):\\)/e',  "Node('$1')");
> function Node($text) {
>   print "<script>alert(\"text=$text\")</script>";
>   return "text=$text<br>";
> }
> 
> 
> If I include markup such as (:node foo:), then this will print the
> "text=foo" as expected but the JS alert will display something like
> "text=9L". :-(
> What am I not understanding?

What value is being provided for the $when parameter?

Note that using 'print' here is probably not what you want, as it
causes the <script>...</script> output to be sent to the browser
when the markup is being processed, as opposed to when the page
is being displayed.  This will cause the <script> tag to appear
at the very beginning of the output (before even the <!DOCTYPE ...>
declaration), as well as cause PHP to generate 
"Warning: Cannot modify header information ..." messages.

Pm



More information about the pmwiki-devel mailing list