pub YouXOR

Language PHP : Hypertext Preprocessor

 Charge moyenne sur 1mn : 0.48 Charge moyenne sur 5mn : 0.18 Charge moyenne sur 15mn : 0.12


PHP

PHP is a popular general-purpose scripting language that is particularly suited for web development.

Fast, flexible and pragmatic, PHP is made for any blog or for all the most popular sites in the world.

The word PHP or programming language contained in web pages and executed on servers, they return the result directly to the client who can never see the source. Allows you to create dynamic web pages.

PHP.Net © 2001-2020 The PHP Group: Language Reference

Predefined PHP classes to make our life easier :)






Site user blocks : Account info / user rights / summary

Function PHP : Writing an Arabic URL using bin2hex - hex2bin

Ecrire une URL Arabe grâce à bin2hex - hex2bin

Informations :

Dates
  • Publish : : Thursday 12 may 2022

  • 340 views

Share :

Je souhaite traduire le mot "Linux" en Arabe pour faire pointer sur un site Web.
Par exemple WikipediA : https://ar.wikipedia.com/wiki/لينكس (Linux)

Pour cela, il faut utiliser la fonction PHP bin2hex qui va créer une chaine hexadécimal et ajouter un % tout les caractères.


Pour décoder - c'est simple - on supprime les % et on utilise la fonction PHP inverse hex2bin.


J'ai fais 2 fonctions simple :

Script avec 30 lignes

001<?php 
002
003function text_bin2hex($text) {
004    
005    $encoded = strToUpper(bin2hex($text));
006    $encoded = chunk_split($encoded, 2, '%');
007    $encoded = '%' . substr($encoded, 0, strlen($encoded) - 1);
008    
009    return $encoded;
010}
011
012function text_hex2bin($text) {
013    
014    $decoded = str_replace('%', '', $text);
015    $decoded = hex2bin($decoded);
016    
017    return $decoded;
018}
019
020$word['fr'] = 'Linux';
021$word['ar'] = 'لينكس';
022
023$langue = 'ar';
024
025echo '<a href="https://'.$langue .'.wikipedia.org/wiki/'.text_bin2hex($word[$langue]).'">WikipediA : '.$word[$langue].'</a>';
026
027// <a href="https://fr.wikipedia.org/wiki/%4C%69%6E%75%78">WikipediA : Linux</a> :/
028// <a href="https://ar.wikipedia.org/wiki/%D9%84%D9%8A%D9%86%D9%83%D8%B3">WikipediA : لينكس</a>
029
030?>

Truc à la c** mais j'avais envie de partager cela.

Cordialement,
Romain





Author of the page

O.Romain.Jaillet-ramey

O.Romain.Jaillet-ramey

  • Firstname : Olivier Romain Luc
  • Lastname : : Jaillet-ramey
  • Arrived on tuesday 19 october 1976 (1976/10/19 00:00)
    48 years activity !

Translate this page with Google



ZW3B.Net



Load page: 2.507266998291