Posted by Ian McConnell on 12/20/74 11:44
"Kimmo Laine" <spam@outolempi.net> writes:
> "Emil" <emjot_wytnij_to_@podczta.onet.pl> wrote in message
> news:e15ag1$3ee$1@news.onet.pl...
>> Is there any hope that new versions of PHP
>> will support macros similar to C or C++?
>> I've searched manual and didn't find anything
>> except define directive, but it can be used
>> to define constant values only.
>> Of course it is not THAT neccessary functionality,
>> but it could be very useful.
>>
>
>
> What's the actual difference between a function and a macro? How would use
> of macros differ from functions?
Just the other day, I was thinking that a preprocessor in PHP would be
handy. I've got a lot of code that goes
<?php
include 'cache.inc';
$c = new cache;
if ($c->uncached()) {
... main body of php code
}
$c->end(); // cache and/or display html
include 'stats_counter.inc';
?>
It would be nice to replace this with
<?php
START_CACHING;
... main body of php code
END_CACHING;
?>
but I can't see how this can be done neatly[*] with functions.
Ian
[*] It could be done badly with cache.php?inc=mycode.php where
cache.php is something like
<?php
include 'cache.inc';
$c = new cache;
if ($c->uncached()) {
include $_GET['inc'];
}
$c->end(); // cache and/or display html
include 'stats_counter.inc';
?>
Navigation:
[Reply to this message]
|