You are here: Re: cannot access inc files from a function « PHP Programming Language « IT news, forums, messages
Re: cannot access inc files from a function

Posted by Giannis Vrentzos on 07/29/05 16:32

bettina@coaster.ch wrote:
> I have the following piece of code (symplified)
>
> require("lang.{$lang}.inc.php"); // I include the inc. files
> ...
> function decodify($technique) { // functions that give me back the
> value in inc.file
> switch ($technique) {
> case 'C':
> echo $charcoal;
> break;
> case 'O':
> echo $oil;
> break;
> case 'A':
> echo $acrylic;
> break;
> }
> }
> ....
> Somewhere I call the function ....decodify($myTechnique)
>
> But it doen't print the content from $charcoal, $oil or, etc.
> Do I have to declare the function global or something like that. In
> that case, how should I do it??
> Many thanks. Bettina

You cannot access a variable that is outside of a function unless you
write global $var; inside the function. The other way is to include the
lang file inside the function.

Gvre

 

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

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