You are here: Re: Macros in php « PHP Programming Language « IT news, forums, messages
Re: Macros in php

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация