Bu dosya Ajax ile çağrıldığında bir PHP dosyası bir dizide iç PHP değerleri bir hata görüntüleniyor!

0 Cevap php

I Fancybox kullanarak şu şekilde bir php dosyayı aramak

index.php:

<div class="pic">
            <a id="showcase1" href="showcase/showcase1.php"><img src="images/showcase1t.png"/></a>
        </div><!-- .pic -->

içeride showcase/showcase1.php Ben aşağıdaki kodu var:

<?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>

Bir dil dosyasından bir dizinin içindeki değerleri çağıran (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',

bir "denetleyici" tarafından yardım (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;
?>

Ben doğrudan açık showcase/showcase1.php, ancak Fancybox kullanarak çapa linkten çağrıldığı zaman derse dizi mükemmel dil dosyaları değerlerini görüntüler:

Fatal error: Call to undefined function l() in D:\wamp\www\projects\alexchen\alexchen2.6\showcase\showcase1.php on line 3

Herhangi bir öneriniz?

EDIT: l is an array in the languages files but i use it as a function later (see at the end of localization.php).

0 Cevap