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

Posted by Jiri Fogl on 11/18/71 11:44

> What's the actual difference between a function and a macro? How would use
> of macros differ from functions?

I was working on modular system, where every module was a file with
object definition.

I needed to make some global variables accessible in method of this
object (i.e. database connection object) in every module, but I wanted
to have a list of these variables only once in whole system (it would be
unpleasant to edit all modules if I decided to, for example, change name
of any of these variables).

Function is useless in this case, so I needed a macro.

I solved a problem this way:

// In initialisation part of code
define('MY_MACRO', 'global $database, $global_config,
$any_other_needed_variables;');

// In beginning of module object's method
eval (MY_MACRO);

But maybe there is much better way to do this

 

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

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