Reply to Re: Macros in php

Your name:

Reply:


Posted by Jerry Stuckle on 10/17/74 11:44

Kimmo Laine wrote:
> "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?
>
> Let's pretend there is a way of defining a macro in php...
> define ("MAX($a,$b)", "(($a<$b)?$b:$a)");
>
> vs.
>
> function max( $a, $b ) {
> return $a < $b ? $b : $a;
> }
>
> And use them like this:
> MAX($a,$b); // This is macro, so much easier!
> max($a,$b); // This is plain old dull function! Bah, no no, not like
> this...
>
> I mean.... WTF?
>

Macros are more efficient.

Personally, one construct I use heavily and would like to replace with a macro:

$var = isset($_POST['postvar']) ? $_POST['postvar'] . 'default value';

I use something similar for a get/post, session and cookie values. It would be
very nice to have a macro.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[Back to original 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

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