Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7830085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:04:01+00:00 2026-06-02T11:04:01+00:00

index.php <?php include_once ‘lang.php’; ?> lang.php <?php session_start(); header(‘Cache-control: private’); // IE 6 FIX

  • 0

index.php

<?php include_once 'lang.php'; ?>

lang.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';
}
switch ($lang) {
    case 'en':
        $lang_file = 'lang.en.php';
        break;
    case 'pl':
        $lang_file = 'lang.pl.php';
        break;
}
include_once 'languages/' . $lang_file;
?>

In lang.en.php and lang.pl.php I have arrays with content.

When website is opened for the first time I get two warnings:

Warning: include_once(languages/) [function.include-once]: failed to open stream: No such file or directory in blah/blah/blah/lang.php on line 37

Warning: include_once() [function.include]: Failed opening ‘languages/’ for inclusion (include_path=’.:/usr/local/lib/php-5.2.17/lib/php’) in blah/blah/blah/lang.php on line 37

Then when I select a language on the webpage, and variable "lang" is passed in the url (e.g. index.php?lang=en) everything works ok. How to fix it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T11:04:03+00:00Added an answer on June 2, 2026 at 11:04 am

    Maybe just add a default section for the switch:

    switch($lang){
      case 'en':
        $lang_file='lang.en.php';
        break;
      case 'pl':
        $lang_file='lang.pl.php';
        break;
      default:
        // This will set a default language file.
        $lang_file='lang.en.php';
    }
    include_once 'languages/'.$lang_file;
    

    This time, when $lang is not set to 'en' or 'pl', the switch will return setting the $lang_file to lang.en.php. If you want pl to be set by default, however, you can change that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have my index.php page and just afrer my header i want to include
My PHP site has header,body,footer files that are included into the INDEX.PHP page. On
index.php <?php require_once('fr.php'); header('Location:'.abspath().directory()); ?> fr.php <?php require_once('functions.php'); ?> functions.php function abspath() { return
hoping you can help me out with this question! Index.php include_once 'files.class.php'; $file_object =
when I include vars.php: $var='hello'; in index.php: require 'vars.php'; echo $var; it works great,
I'm developing web page which has main file index.php as follows: include('UserClass.php'); include('html/top.php'); $user
I'm including a PHP script that changes the URL. // index.php ob_start(); include script.php;
I have a index.php file that will include several external files: content/templates/id1/template.php content/templates/id2/template.php content/templates/id3/template.php
is there a demo for the FanBox? http://wiki.developers.facebook.com/index.php/Fan_Box I would like to include it
I have a PHP script (index.php) that includes an index.html file in a sub-directory

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.