[Pmwiki-users] file: and Variables?

Patrick R. Michaud pmichaud
Fri Jan 30 12:22:52 CST 2004


On Fri, Jan 30, 2004 at 08:04:41PM +0100, Thomas -Balu- Walter wrote:
> 
> Thanks for the hint - since I am using 4.1.2 I did:
>         function PrintFile($pagename, $filename)
>         {
>             $filetext = file($filename);
>             foreach ($filetext as $line) {
>                 print FmtPageName($line, $pagename);
>             }
>         }
> 
> What kind of side-effects are you thinking of?

I dunno exactly, but I know from experience they could be there.  
The FmtPageName function is one of the trickiest functions in PmWiki
and several times in the past using it has surprised me with some
unintended side effects.  (Christian is quite correct in saying that
this function needs comments from me.  OTOH, for this function I often 
feel like simply saying "Here be dragons" and letting it go at that. :-)

But now that I think about it, I don't think you even need this
function to do what you want.  :-)  How about simply doing

   $PageFooterFmt = file_get_contents('local/PageFooterFmt.html');

or, in PHP 4.1,

   $PageFooterFmt = join('',file('local/PageFooterFmt.html'));

Then you don't need the function: or file: reference at all.  If
you want the filename to be based on the current page, then

   $PageFooterFmt = join('',
     file(FmtPageName('local/$Group.$Title_.html',$pagename)));

Pm



More information about the pmwiki-users mailing list