Teste - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of Teste.php

  1. <?php
  2.  
  3.  
  4. function bestSignEncode(string $name, $email=null, $tel=null){
  5.         $array = [$name, $email, $tel];
  6.         $json = json_encode($array);
  7.         $base64 = base64_encode($json);
  8.         $special = strtr($base64,['+'=>'-','/'=>',','=='=>';','='=>':']);
  9.         $array = str_split($special);
  10.         $even = '';
  11.         $odd = '';
  12.         foreach ($array as $k => $v){
  13.                 if ($k === 0 || $k % 2 == 0) $even .= $v;
  14.                 else $odd .= $v;
  15.         }
  16.         return $odd.'_'.$even;
  17. }
  18.  
  19.  
  20. function bestSignDecode(string $str){
  21.         $oe = explode('_', $str);
  22.         $odd = $oe[0];
  23.         $even = $oe[1];
  24.         $length = max(strlen($odd),strlen($even));
  25.         $special = '';
  26.         for ($i=0; $i<$length; $i++){
  27.                 $special .= $even[$i] . $odd[$i];
  28.         }
  29.         $base64 = strtr($special,['-'=>'+',','=>'/',':'=>'=',';'=>'==']);
  30.         return base64_decode($base64);
  31. }
  32.  
  33. $encoded = bestSignEncode('BEST','[email protected]','123456');
  34.  
  35. echo $encoded;
  36.  
  37. echo "\n";
  38.  
  39. $decoded = bestSignDecode($encoded);
  40. echo $decoded;
  41.  
File Description
  • Teste
  • PHP Code
  • 05 Feb-2021
  • 885 Bytes
You can Share it: