Re: cannot access inc files from a function
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.php archive

Re: cannot access inc files from a function

From: jamen <jamen@invalid>
Date: Fri Jul 29 2005 - 16:48:00 CEST

bettina@coaster.ch wrote:
> How should I define the global variable inside this function? What must
> be global is the lang.{$lang}.inc.php so that it can be read inside the
> function

> require("lang.{$lang}.inc.php");
> function technique($t) {
> switch ($t) {
> case 'C':
> echo $charcoal;
>...

$charcoal is local to your function. You can do it in two ways..

1.
function technique($t) {
        global $charcoal;

        switch ($t) {
                case 'C':
                     echo $charcoal;

2.
function technique($t) {
        switch ($t) {
                case 'C':
                     echo $GLOBAL['charcoal'];
Received on Mon Oct 24 02:09:08 2005