m0zus Posted November 23, 2006 Author Report Share Posted November 23, 2006 http://bh.deals.lv/source/cookie.phpZinkas te ir? Tas ka jauzspiezh 2reiz uz linka kur jamaina valoda lai <?php echo $val; ?> izvadiitu pareizo. lab, tas nav tik buutiski, bet ja man vaig sho rindinju aizstaat ar include("lang/" . $val . ".php"); tad man vaig lai to izvada uzreiz(pareizu) un kaa to panaakt? Link to comment Share on other sites More sharing options...
savejais Posted November 25, 2006 Report Share Posted November 25, 2006 Nu nez es jau darītu tā: index.php <?php setcookie("lng", "eng"); ?> un tālāk <?php if($_COOKIE["lng"] = eng) {header("Location: anglu_versija.php");} ?> Link to comment Share on other sites More sharing options...
m0zus Posted November 30, 2006 Author Report Share Posted November 30, 2006 <?php if ($_COOKIE["dream_lang"] = ru) {include 'lang/ru.php';} elseif ($_COOKIE["dream_lang"] = lv) {include 'lang/lv.php';} elseif ($_COOKIE["dream_lang"] = en) {include 'lang/en.php';} else {include 'lang/en.php';} ?> Var kads pateikt kas seit ir nepareizi? Vins includo tikai ru.php kaut cookijs ir lv ... Link to comment Share on other sites More sharing options...
john.brown Posted November 30, 2006 Report Share Posted November 30, 2006 Nu bet jāatšķir tak piešķiršana no salīdzināšanas ;) if ($_COOKIE["dream_lang"] == ru)... Link to comment Share on other sites More sharing options...
Stopp Posted November 30, 2006 Report Share Posted November 30, 2006 Un liec vērtības starp pēdiņām. Ja iet arī bez tām, tas nekas. Vismaz būs labs stils, t.i. nebūs problēmu vēlāk. Link to comment Share on other sites More sharing options...
ok1 Posted November 30, 2006 Report Share Posted November 30, 2006 (edited) Vispār labāk lietot switch: <?php if($_REQUEST['set_lang']){ if($_REQUEST['set_lang'] == "lv" OR $_REQUEST['set_lang'] == "en" OR $_REQUEST['set_lang'] == "ru"){ setcookie("dream_lang",$_REQUEST['set_lang']); } } switch($_COOKIE["dream_lang"]){ case 'en': //anglju valoda - ja izveeleeta include("lang/en.php"); break; case 'lv': //latvieshu valoda, ja izveeleeta include("lang/lv.php"); break; case 'ru': //krievu valoda, ja izveleta include("lang/ru.php"); break; default: //galvenaa valoda include("lang/en.php"); break; } ?> <a href="<?php echo $_SERVER['PHP_SELF']; ?>?set_lang=lv">Mainīt valodu uz LV</a> <a href="<?php echo $_SERVER['PHP_SELF']; ?>?set_lang=en">Mainīt valodu uz EN</a> <a href="<?php echo $_SERVER['PHP_SELF']; ?>?set_lang=ru">Mainīt valodu uz RU</a> Edited November 30, 2006 by ok1 Link to comment Share on other sites More sharing options...
Val Posted November 30, 2006 Report Share Posted November 30, 2006 A special case is the default case. This case matches anything that wasn't matched by the other cases, and should be the last case statement. Link to comment Share on other sites More sharing options...
bubu Posted November 30, 2006 Report Share Posted November 30, 2006 Ko tu gribēji ar to teikt, Val? Link to comment Share on other sites More sharing options...
Val Posted November 30, 2006 Report Share Posted November 30, 2006 Tagad vairs neko. Iepriekš ok1 bija uzcepis switchu ar default gadījumu kā pirmo. Link to comment Share on other sites More sharing options...
Recommended Posts