So as many of you astute readers may have noticed, we use PHP on the backend. Nathan and I ran into a curious quirk today; if you do a require_once() in a function’s context, the variables set in the required file are not visible as globals once the function returns, even to functions in the required file.
The moral of the story? If you use globals in your includes, put all the require_once()s that you might need at the top of your PHP. Don’t try and be clever with conditional inclusion of your libraries.
Here’s a simple test case to reproduce:
test.inc
$var = “foo”;
function f() {global $var;
die($var);}
?>
test.php
function a() {
require_once(‘test.inc’);
}
a();
f();
?>
Àóäèî-Âèäåî, Áûòîâàÿ òåõíèêà ñî ñêëàäà. Âåñü àññîðòèìåíò. Ñòèðàëüíûå ìàøèíû, òåëåâèçîðû, âñòðîéêà, õîëîäèëüíèêè, êîíäèöèîíåðû, ïîñóäîìîå÷íûå, øâåéíûå ìàøèíû è äðóãîå. Áåñïëàòíàÿ îðãàíèçàöèÿ äîñòàâêè ïî Êèåâó. Ãàðàíòèÿ. Ñêëàäñêèå öåíû.
Òåë.: (44) 233-03-96, (44) 332-60-75, (67) 947-19-49, ìîá. (67) 947-19-49
Web: http://www.shtepsell.net.ua
Каждому Добрый день! Заходите на Грузоперевозки по Мо�кве и обла�ти. Гузоперевозки в любую точку на карте Ро��и� и С�Г
Pretty nice post. I just stumbled upon your weblog and wanted to say that I’ve truly enjoyed surfing around your blog posts.
After all I’ll be subscribing to your rss feed and
I hope you write again soon!
buzagda.ucoz.com mezilar.rurs.net mezilar.netii.net kazrazuru.netii.net kazrazuru.besaba.com vudomi.besaba.com vudomi.6te.net dusida.besaba.com dusida.netne.net coilis.besaba.com coilis.host22.com daijinn.besaba.com daijinn.host22.com bralen.besaba.com bralen.host22.com brazius.besaba.com gholbira.besaba.com gholbira.comxa.com +79185540950 (Viber,WhatsApp) Владимир