xampp  Notice: Undefined variable: gsLanguage

Posted on 2014-08-26
Last Modified: 2014-08-30
On my host the code works fine . .but on the xampp I get this error. Is there anything I need to enable on XAMPP?
Question by:Starquest321
    LVL 82

    Assisted Solution

    by:Dave Baldwin
    It sounds like you're missing the file that defines 'gsLanguage'.
    LVL 11

    Assisted Solution

    What platform are you running XAMPP on, what version of XAMPP are you running and what web application are you hosting i.e. the one that generates this error?
    LVL 107

    Assisted Solution

    by:Ray Paseur
    I'm going to guess a bit here and say this almost looks like a PHP Notice-level message.  See my example here:

    <?php // demo/temp_starquest321.php
    $x = $gsLanguage;

    Open in new window

    By way of explanation, the default configuration of PHP causes Notice-level messages to be suppressed.**  This allows you to use undefined variables as if they were equal to the generic "falsy" values of zero, NULL, FALSE, etc.  If you visualize the Notice-level messages (see line 2 of the code snippet), PHP will tell you when your script relies on an undefined variable.

    You can see your error_reporting() level by running phpinfo().  You can turn off Notice messages with the error_reporting() setting shown below, however I would fire a programmer who did this.  The right answer is not to suppress messages, but to find and correct the underlying Notice, Warning and Error conditions!
    error_reporting(E_ALL ^ E_NOTICE);

    Open in new window

    PHP error_reporting is also settable in php.ini.

    ** Default settings in current PHP: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED

    Author Comment

    You are all correct:

    Official answer from support:

    If you enable error_reporting(E_ALL), PHP will report everything, including notices.
    $gsLanguage is a variable declared in config*.php, if your page does not include it and you use it without declaring yourself, you get the notice.

    Where do I set the error reporting? Is it in the php.ini?
    LVL 107

    Expert Comment

    by:Ray Paseur
    Where do I set the error reporting? Is it in the php.ini?
    Please read the answer that was posted yesterday in this link:
    The right answer is not to suppress messages, but to find and correct the underlying Notice, Warning and Error conditions!
    LVL 82

    Accepted Solution

    On shared hosting where you do not have access to php.ini, you have to put the error reporting line error_reporting(E_ALL); at the top of every page that you need to check.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
    These days socially coordinated efforts have turned into a critical requirement for enterprises.
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now