How to create a simple PHP cookie language toggle?

前端 未结 5 1334
我寻月下人不归
我寻月下人不归 2020-12-14 04:56

I\'m trying to set up, what I thought would be, a simple language switch. I thought I\'d use PHP cookies, but they\'re not behaving as intended.

I\'ve read a few coo

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-14 05:19

    I used PHP's $_SERVER['PHP_SELF'] to refresh current page and take into account the language selected.

    Sample code enclosed. file name : language_switcher.php

    
    
    
    
    
        Test Page Language Toggle
        
    
    
    
    
         array(
                'selectlang' => 'Select Language',
                'lingua' => 'Language: ',
                'filename' => 'You are in this location: '
              ),
          'fr' => array(
                'selectlang' => 'Séléctionner',
                'lingua' => 'Langue: ',
                'filename' => 'Vous lisez ce fichier: '
              )
          );
    
        ?>
    
        

    not set"; } ?>


提交回复
热议问题