|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-03-25 11:22 UTC] felipe@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 27 04:00:01 2025 UTC |
Description: ------------ Can't post following code-example Reproduce code: --------------- Following example takes placeholders formatted like this: [[name,parameter1,parameter2]] and replaces it with the results for function calls: name(parameter1,parameter2). This enabled me to make websites in a very convenient way. The @ symbol before the function call surpresses the warnings you'd otherwise see on your screen if you'd not provide the number of parameters that the function(s) expect. Let me know what you think. <?php function test($a,$b) { $c=$a*$b; if(!$a)$a="NULL"; if(!$b)$b="NULL"; return("function <b>test()</b> says if you multiply $a and $b you might end up with $c"); } function testtwo($a,$b) { $c=$a." ".$b; return("function <b>testtwo()</b> says that: ".$c."!"); } $template="<html><body>[[test]]<br />[[test,17]]<br />[[test,18,3]]<p>[[testtwo,textpad,rocks]]</body></html>"; $template=preg_replace('/\[\[([a-z]+)\,?([0-9a-zA-Z]*)(\,?)([0-9a-zA-Z]*)]]/e','@$1($2 $3 $4)',$template); print $template; ?> Expected result: ---------------- post note. Actual result: -------------- your text is to long even after wordwrap... ??