Reply to Re: Macros in php

Your name:

Reply:


Posted by Jerry Stuckle on 11/18/06 11:45

Oli Filth wrote:
> Oli Filth said the following on 09/04/2006 13:44:
>
>> Jerry Stuckle said the following on 09/04/2006 06:14:
>>
>>> Oli Filth wrote:
>>>
>>>> I have error level set to E_ALL | E_STRICT. The following code
>>>> executes fine:
>>>> <?php
>>>>
>>>> function getValueWithDefault(&$array, $key, $default = NULL)
>>>> {
>>>> return (isset($array[$key])) ? $array[$key] : $default;
>>>> }
>>>>
>>>> $var = array();
>>>> echo getValueWithDefault($var, "Roger", "Dodger") . "\n";
>>>>
>>>> ?>
>>>
>>> Take out the $var=array() line and see what you get.
>>
>>
>> But anyway, removing the $var = array() line does not result in any
>> error/warning. Because it's being passed by reference, PHP
>> automatically creates a variable $var in the global scope
>
>
> That should be *caller* scope...
>
>

OK, you want to argue with everyone who supports the idea of macros. Fine.
Let's see you to this as easily and as cleanly without macros:

define('FOREACH(X, K, V)', 'if (isset(X) && isarray(X)) foreach(X as K=>V)


FOREACH($var,$key,$value) {

// Process data in $key=>$value here.
}

FOREACH($var2, $key2, $value2) {
// Different processing of $key2=>value2 here
}
--
==================
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

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