I call a php file in the following way using Fancybox
index.php:
<div class="pic">
<a id="showcase1" href="showcase/showcase1.php"><img src="images/showcase1t.png"/></a>
</div><!-- .pic -->
inside showcase/showcase1.php
I have the following code:
<?php include_once '../localization.php'; ?>
<div id="inline">
<img src="images/showcase2.png"/>
<?php echo l('inline_p'); ?>
<a href="http://studyatbest.com"><?php echo l('inline_a'); ?></a>
</div>
which calls values inside an array from a language file (lang.en.php
):
'inline_p' => ' <p><strong>Previous</strong> = Left Arrow Key</p>
<p><strong>Next</strong> = Right Arrow Key</p>
<p><strong>Close</strong> = Esc</p>',
'inline_a' => 'Visit',
helped by a "controller" (localization.php
):
<?php
session_start();
header('Cache-control: private'); // IE 6 FIX
if(isSet($_GET['lang'])) {
$lang = $_GET['lang'];
// register the session and set the cookie
$_SESSION['lang'] = $lang;
setcookie("lang", $lang, time() + (3600 * 24 * 30));
}
else if(isSet($_SESSION['lang'])) {
$lang = $_SESSION['lang'];
}
else if(isSet($_COOKIE['lang'])) {
$lang = $_COOKIE['lang'];
}
else {
$lang = 'en';
}
// use appropiate lang.xx.php file according to the value of the $lang
switch ($lang) {
case 'en':
$lang_file = 'lang.en.php';
break;
case 'es':
$lang_file = 'lang.es.php';
break;
case 'zh-tw':
$lang_file = 'lang.zh-tw.php';
break;
case 'zh-cn':
$lang_file = 'lang.zh-cn.php';
break;
default:
$lang_file = 'lang.en.php';
}
//translation helper function
function l($localization) {
global $lang;
return $lang[$localization];
}
include_once 'languages/'.$lang_file;
?>
The array displays the values in the language files perfectly if I directly open showcase/showcase1.php
, but when it is called from the anchor link using fancybox it says:
Fatal error: Call to undefined function l() in D:\wamp\www\projects\alexchen\alexchen2.6\showcase\showcase1.php on line 3
Any suggestions?
EDIT:
l
is an array in the languages files but i use it as a function later (see at the end of localization.php).