Re: script preprocessor?
| From: | Hugh Bothwell | Date: | Wed, 29 Aug 2001 12:44:42 +0000 |
| Subject: | Re: script preprocessor? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-65006@lists.php.net to get a copy of this message | ||
<alvarez@sto13.st-oneline.de> wrote in message
news:200108291024.MAA20865@sto13.st-oneline.de...
>
> Is there a macro preprocessor that can be used to substitute arbitrary
> sections of code with different code? define is documented as working
> for rvals only and my attempts to produce something more meaty lead to
> parse errors.
You could define the code as a function, then check which version of the
function to use...
<?php
define("DEBUG", true);
if (defined("DEBUG") and DEBUG==true) {
function myMacroizedCode() {
echo "This is debug-mode code";
}
}
else {
function myMacroizedCode() {
echo "This is non-debug code";
}
}
for ($i = 0; $i < 100; $i++)
myMacroizedCode();
?>