3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Is the domain a typo for a common domain * * @param $domain - domain without leading @ symbol (i.e. gmail.com) * * @return bool - true if $domain is a typo, false if not */ function isCommonTypo($domain) { $commonDomains = array( 'gmail.com', 'aol.com', 'icloud.com', 'aol.com', 'hotmail.com', 'outlook.com', 'yahoo.com', ); $domain = strtolower($domain); foreach ($commonDomains as $commonDomain) { similar_text($commonDomain, $domain, $percent); //var_dump($commonDomain, $domain, $percent, ($percent >= 75 && $percent < 100));die(); if ($percent >= 75 && $percent < 100) { var_dump($percent);die(); return true; } } return false; } $typo_domains = array( 'gmail.com' => array ( 'gmail.com', 'gmail.con', 'gamil.com', 'gmai.com', 'gmil.com', 'gmail.co', 'gmal.com', 'gmeil.com', 'gmsil.com', 'gnail.com', 'gmail.net', 'gmial.com', 'gmaile.com', 'gail.com', 'gemail.com', 'gmaill.com', 'google.com', 'g.mail.com', 'gmail.cim', 'gamail.com', 'gimail.com', 'gmail.com.com', 'gmail.comm', 'gmail.c', 'gmile.com', 'g-mail.com', 'gmail.co.com', 'gmail.ca', 'gmail.cm', 'gmail.xom', 'gimel.com', 'gmail.come', 'gmall.com', 'gmale.com', 'gimil.com', 'gmaim.com', 'gmaik.com', 'gimal.com', 'gmail.cpm', 'gmaol.com', 'gmali.com', 'gmail.vom', 'gmaul.com' ), 'yahoo.com' => array ( 'yhaoo.com', 'yahoo.con', 'yaoo.com', 'yahho.com', 'yhoo.com', 'yohoo.com', 'yaho.com', 'yahoo.com.my' ), 'aol.com' => array ( 'ail.com', 'aol.con' ), 'hotmail.com' => array ( 'hotmail.con', 'hitmail.com', 'hotmai.com', 'hotmail.con' ), 'outlook.com' => array ( 'outloo.com', 'outlook.con' ), 'icloud.com' => array ( 'icould.com', 'icloud.con', 'iclound.com', 'icloud.con' ) ); foreach($typo_domains as $key => $domain_node) { foreach($domain_node as $domain) { if (isCommonTypo($domain)) { echo "{$domain} is a common typo for {$key}!\n"; } else { echo "{$domain} is not a typo\n"; } } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 22
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 22
Branch analysis from position: 3
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 20
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 20
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 16
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 20
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
filename:       /in/65uc8
function name:  (null)
number of ops:  24
compiled vars:  !0 = $typo_domains, !1 = $domain_node, !2 = $key, !3 = $domain
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   ASSIGN                                                   !0, <array>
   47     1      > FE_RESET_R                                       $5      !0, ->22
          2    > > FE_FETCH_R                                       ~6      $5, !1, ->22
          3    >   ASSIGN                                                   !2, ~6
   48     4      > FE_RESET_R                                       $8      !1, ->20
          5    > > FE_FETCH_R                                               $8, !3, ->20
   49     6    >   INIT_FCALL                                               'iscommontypo'
          7        SEND_VAR                                                 !3
          8        DO_FCALL                                      0  $9      
          9      > JMPZ                                                     $9, ->16
   50    10    >   ROPE_INIT                                     4  ~11     !3
         11        ROPE_ADD                                      1  ~11     ~11, '+is+a+common+typo+for+'
         12        ROPE_ADD                                      2  ~11     ~11, !2
         13        ROPE_END                                      3  ~10     ~11, '%21%0A'
         14        ECHO                                                     ~10
   49    15      > JMP                                                      ->19
   52    16    >   NOP                                                      
         17        FAST_CONCAT                                      ~13     !3, '+is+not+a+typo%0A'
         18        ECHO                                                     ~13
   48    19    > > JMP                                                      ->5
         20    >   FE_FREE                                                  $8
   47    21      > JMP                                                      ->2
         22    >   FE_FREE                                                  $5
   55    23      > RETURN                                                   1

Function iscommontypo:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 25
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 25
Branch analysis from position: 8
2 jumps found. (Code = 46) Position 1 = 15, Position 2 = 17
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 24
Branch analysis from position: 18
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 17
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/65uc8
function name:  isCommonTypo
number of ops:  28
compiled vars:  !0 = $domain, !1 = $commonDomains, !2 = $commonDomain, !3 = $percent
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   11     1        ASSIGN                                                   !1, <array>
   21     2        INIT_FCALL                                               'strtolower'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $5      
          5        ASSIGN                                                   !0, $5
   23     6      > FE_RESET_R                                       $7      !1, ->25
          7    > > FE_FETCH_R                                               $7, !2, ->25
   24     8    >   INIT_FCALL                                               'similar_text'
          9        SEND_VAR                                                 !2
         10        SEND_VAR                                                 !0
         11        SEND_REF                                                 !3
         12        DO_ICALL                                                 
   26    13        IS_SMALLER_OR_EQUAL                              ~9      75, !3
         14      > JMPZ_EX                                          ~9      ~9, ->17
         15    >   IS_SMALLER                                       ~10     !3, 100
         16        BOOL                                             ~9      ~10
         17    > > JMPZ                                                     ~9, ->24
   27    18    >   INIT_FCALL                                               'var_dump'
         19        SEND_VAR                                                 !3
         20        DO_ICALL                                                 
         21      > EXIT                                                     
   28    22*       FE_FREE                                                  $7
         23*       RETURN                                                   <true>
   23    24    > > JMP                                                      ->7
         25    >   FE_FREE                                                  $7
   32    26      > RETURN                                                   <false>
   33    27*     > RETURN                                                   null

End of function iscommontypo

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.91 ms | 1020 KiB | 17 Q