Hi all,

I have a problem , I use codeiniter framework. it shows an error from the framework file.

I got the following error

A PHP Error was encountered

Severity: Warning

Message: array_key_exists() [function.array-key-exists]: The first argument should be either a string or an integer

Filename: core/MY_Lang.php

Line Number: 155


but I cudbt find
Filename: core/MY_Lang.php


and I get the following error also

A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /home/xxxxxx/domains/xxxxxxx.com/public_html/system/core/Exceptions.php:170)

Filename: core/MY_Lang.php

Line Number: 75

both errors occured from the fram work. but site is working properly.
only the google cash copy view this and it says latest site my be changed.
acutually this is happening from now few months.

site working properly. only the cash copy has above error.

it is ugly to find the first link in google for my site has above error.

thanks,
menukadevinda.

Dani AI

Generated

Short answer for : the cached Google snapshot is showing PHP warnings from your CodeIgniter language override while ordinary visitors don’t see them. Those warnings usually mean a non-scalar value reached PHP’s array_key_exists and then a header/send problem appeared because output (the warning) was already sent. First checks: look for a custom language class in application/core (MY_Lang.php), inspect your server error log, and make sure PHP is configured to log errors instead of printing them on live pages. CodeIgniter language docs. PHP array_key_exists documentation. (codeigniter.com)

A common and simple fix is to guard the language-key lookup so only a valid scalar key is passed to array_key_exists. For example:

function default_lang()
{
    $browser = !empty($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? strtok(strip_tags($_SERVER['HTTP_ACCEPT_LANGUAGE']), ',') : '';
    $browser = substr($browser, 0, 2);
    if (!empty($browser) && is_scalar($browser) && array_key_exists($browser, $this->languages)) {
        return $browser;
    }
    return 'en';
}

That prevents the warning when the server variable is missing (cron/CLI runs often omit HTTP headers). Similar solutions appear in community answers for MY_Lang. (stackoverflow.com)

About the header warning: it’s usually a secondary effect — PHP can’t send headers after any output has started (including warnings). Check for whitespace or a BOM in included files, use headers_sent() to find where output began, and disable on-screen error display on production (use log_errors instead). See PHP’s notes on headers and runtime error configuration. headers_sent() docs. Error-display / logging guidance. (php.net)

Why Google cached it and how to clear the cache: Google caches whatever it crawled. After fixing the code/config and confirming the live page is clean, request a re-crawl with Search Console’s URL Inspection / Request Indexing (or resubmit a sitemap) so the cached snapshot updates. Also purge any server-side caches before asking Google to reindex. Ask Google to recrawl (Search Central). (developers.google.com)

Relevant notes: pointed to similar community threads — those confirm the same root causes (missing server headers or unguarded keys). If the file truly isn’t in application/core, search the codebase for MY_Lang or any language override and fix the default_lang() guard there, then turn off display_errors on the live site so crawlers don’t capture transient warnings.

Member Avatar for Member #949455

google cash has error of my site but site works properly.

I think someone has an answer to the issue you are having:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.