ztealmax Posted December 18, 2006 Share Posted December 18, 2006 hi im trying to include a language file with some scripts for example like this:this is my [b]index.php[/b][code]<?php include("language.php?language=config/language.cfg"); ?><? echo lan_0; ?>[/code]this is my [b]language.php[/b][code]<?php$file = $_GET['language'];$fh = fopen($file, 'r') /*or die('Could not open file!')*/;$data = fread($fh, filesize($file)) /*or die('Could not read file!')*/;fclose($fh); ?><pre><?php require_once("languages/$data.php"); ?></pre>[/code]and this is my [b]language.cfg[/b][code]svenska[/code]and finally the language file[code]<?php// Language Svenskadefine("lan_0", "Svenska");// Mainmenudefine("lan_1", "Huvudmeny");define("lan_2", "Nyheter");define("lan_3", "länkar");define("lan_4", "forum");define("lan_5", "Nedladdningar");define("lan_6", "Medlemmar");?>[/code]so i want to be able to access the defined values for example[b]lan_0[/b] thats says what langueage it is. but i must be doing a fatal mistace couse all i get isechoed out:lan_0 ([i]here it should say[/i] [b]svenska[/b])So if you know how to solve this, or know what i did wrong please post it ;)Thanx //Martin Link to comment https://forums.phpfreaks.com/topic/31086-more-stuff-about-include-and-defined-data/ Share on other sites More sharing options...
ztealmax Posted December 18, 2006 Author Share Posted December 18, 2006 Anyone have any thoughts how to do this correctly? ;) Link to comment https://forums.phpfreaks.com/topic/31086-more-stuff-about-include-and-defined-data/#findComment-143646 Share on other sites More sharing options...
ztealmax Posted December 19, 2006 Author Share Posted December 19, 2006 Still need some help with this guys and girls :Dany help is really helpfull :D Link to comment https://forums.phpfreaks.com/topic/31086-more-stuff-about-include-and-defined-data/#findComment-144287 Share on other sites More sharing options...
btherl Posted December 19, 2006 Share Posted December 19, 2006 Are you sure this makes sense:[code=php:0]include("language.php?language=config/language.cfg");[/code]If you want to pass a variable to an included file, just set it like this:[code=php:0]$language = 'config/language.cfg';include('language.php');[/code]$language will be available inside the included file. Link to comment https://forums.phpfreaks.com/topic/31086-more-stuff-about-include-and-defined-data/#findComment-144309 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.