You are here: Re: Variable scoping - issues with global and multiple includes « PHP Programming Language « IT news, forums, messages
Re: Variable scoping - issues with global and multiple includes

Posted by hrishikesh.mehendale on 04/10/06 23:29

argh! stupid gmail posting system that kills formatting !!!

Reformatted, here is my original query:

Hi All,

Sorry if I'm just repeating other questions, but I can't find an answer
for this particular problem:

I have my main index.php file, which looks so:

<?php

include "includes/header.php"; #defines a global variable called $lang

include "includes/functions.php"; # some required functions

safe_include "main_page.html"; # user-defined function that tries to

# include main_page.html.$lang or gives a
warning message

echo "Language available to index.php at line XYZ is -$lang-";

include "includes/footer.php"; #page footer

?>

and header.php looks so:
<?php
global $lang;
$lang = "en";
?>

footer.php looks like so:
<?php
echo "Language is set to -$lang-";
?>

Now the problem is, the $lang variable is available to all statements
in between, upto and including the safe_include statement.

Unfortunately, footer.php refuses to see the variable. What can be the
problem?

Thanks Hrishikesh

 

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

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