3v4l.org

run code in 300+ PHP versions simultaneously
<?php function show_star_rating_review($rating): string { //global $post; //$rating = get_field('rating', $post); [$whole, $decimal] = explode('.', $rating); $css = <<<CSS <style> .awb-stars-rating-1 .awb-stars-rating-filled-icon{ margin-right:2px; color:#ffd041; } .awb-stars-rating-1 .awb-stars-rating-empty-icon, .awb-stars-rating-1 .awb-stars-rating-partial-icon-wrapper{ margin-right:2px; } .awb-stars-rating-1 .awb-stars-rating-partial-icon{ color:#ffd041; } .awb-stars-rating-1 .awb-stars-rating-icons-wrapper{ color:#dbdbdb; font-size:23px; } </style> CSS; $stars['whole'] = str_repeat("<i class=\"fa-star fas awb-stars-rating-filled-icon\"></i>\n ", $whole); if ($decimal) { $stars['piece'] = sprintf( "<i class=\"fa-star fas awb-stars-rating-partial-icon-wrapper\"> <i class=\"fa-star fas awb-stars-rating-partial-icon\" style=\"width:%d0%%;\"></i> </i>\n ", $decimal ); } $stars['empty'] = str_repeat("<i class=\"fa-star fas awb-stars-rating-empty-icon\"></i>\n ", 5 - ceil($rating)); return sprintf( '%s <div class="awb-stars-rating awb-stars-rating-1 awb-stars-rating-no-text" aria-label="Rating: %s out of 5"> <div class="awb-stars-rating-icons-wrapper"> %s </div> </div>', $css, $rating, implode($stars) ); } $ratings = ['1.0', '1.5', '2.0', '2.7', '3.0', '3.6', '4.0', '4.9', '5.0']; foreach ($ratings as $rating) { echo show_star_rating_review($rating); echo "\n---\n"; }

Abusive script

This script was stopped while abusing our resources

Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 9
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 9
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/ggClq
function name:  (null)
number of ops:  11
compiled vars:  !0 = $ratings, !1 = $rating
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   53     0  E >   ASSIGN                                                   !0, <array>
   54     1      > FE_RESET_R                                       $3      !0, ->9
          2    > > FE_FETCH_R                                               $3, !1, ->9
   55     3    >   INIT_FCALL                                               'show_star_rating_review'
          4        SEND_VAR                                                 !1
          5        DO_FCALL                                      0  $4      
          6        ECHO                                                     $4
   56     7        ECHO                                                     '%0A---%0A'
   54     8      > JMP                                                      ->2
          9    >   FE_FREE                                                  $3
   57    10      > RETURN                                                   1

Function show_star_rating_review:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 24
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/ggClq
function name:  show_star_rating_review
number of ops:  47
compiled vars:  !0 = $rating, !1 = $whole, !2 = $decimal, !3 = $css, !4 = $stars
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    7     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '.'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $5      
          5        FETCH_LIST_R                                     $6      $5, 0
          6        ASSIGN                                                   !1, $6
          7        FETCH_LIST_R                                     $8      $5, 1
          8        ASSIGN                                                   !2, $8
          9        FREE                                                     $5
    9    10        ASSIGN                                                   !3, '++++%3Cstyle%3E%0A++++.awb-stars-rating-1+.awb-stars-rating-filled-icon%7B%0A++++++++margin-right%3A2px%3B%0A++++++++color%3A%23ffd041%3B%0A++++%7D%0A++++.awb-stars-rating-1+.awb-stars-rating-empty-icon%2C%0A++++.awb-stars-rating-1+.awb-stars-rating-partial-icon-wrapper%7B%0A++++++++margin-right%3A2px%3B%0A++++%7D%0A++++.awb-stars-rating-1+.awb-stars-rating-partial-icon%7B%0A++++++++color%3A%23ffd041%3B%0A++++%7D%0A++++.awb-stars-rating-1+.awb-stars-rating-icons-wrapper%7B%0A++++++++color%3A%23dbdbdb%3B%0A++++++++font-size%3A23px%3B%0A++++%7D%0A++++%3C%2Fstyle%3E'
   29    11        INIT_FCALL                                               'str_repeat'
         12        SEND_VAL                                                 '%3Ci+class%3D%22fa-star+fas+awb-stars-rating-filled-icon%22%3E%3C%2Fi%3E%0A+++++++++++++++++'
         13        SEND_VAR                                                 !1
         14        DO_ICALL                                         $12     
         15        ASSIGN_DIM                                               !4, 'whole'
         16        OP_DATA                                                  $12
   30    17      > JMPZ                                                     !2, ->24
   31    18    >   INIT_FCALL                                               'sprintf'
   32    19        SEND_VAL                                                 '%3Ci+class%3D%22fa-star+fas+awb-stars-rating-partial-icon-wrapper%22%3E%0A+++++++++++++++++++++%3Ci+class%3D%22fa-star+fas+awb-stars-rating-partial-icon%22+style%3D%22width%3A%25d0%25%25%3B%22%3E%3C%2Fi%3E%0A+++++++++++++++++%3C%2Fi%3E%0A+++++++++++++++++'
   35    20        SEND_VAR                                                 !2
   31    21        DO_ICALL                                         $14     
         22        ASSIGN_DIM                                               !4, 'piece'
   35    23        OP_DATA                                                  $14
   38    24    >   INIT_FCALL                                               'str_repeat'
         25        SEND_VAL                                                 '%3Ci+class%3D%22fa-star+fas+awb-stars-rating-empty-icon%22%3E%3C%2Fi%3E%0A+++++++++++++++++'
         26        INIT_FCALL                                               'ceil'
         27        SEND_VAR                                                 !0
         28        DO_ICALL                                         $16     
         29        SUB                                              ~17     5, $16
         30        SEND_VAL                                                 ~17
         31        DO_ICALL                                         $18     
         32        ASSIGN_DIM                                               !4, 'empty'
         33        OP_DATA                                                  $18
   40    34        INIT_FCALL                                               'sprintf'
   41    35        SEND_VAL                                                 '%25s%0A+++++++++%3Cdiv+class%3D%22awb-stars-rating+awb-stars-rating-1+awb-stars-rating-no-text%22+aria-label%3D%22Rating%3A+%25s+out+of+5%22%3E%0A+++++++++++++%3Cdiv+class%3D%22awb-stars-rating-icons-wrapper%22%3E%0A+++++++++++++++++%25s%0A+++++++++++++%3C%2Fdiv%3E%0A+++++++++%3C%2Fdiv%3E'
   47    36        SEND_VAR                                                 !3
   48    37        SEND_VAR                                                 !0
   49    38        INIT_FCALL                                               'implode'
         39        SEND_VAR                                                 !4
         40        DO_ICALL                                         $19     
         41        SEND_VAR                                                 $19
   40    42        DO_ICALL                                         $20     
   49    43        VERIFY_RETURN_TYPE                                       $20
         44      > RETURN                                                   $20
   51    45*       VERIFY_RETURN_TYPE                                       
         46*     > RETURN                                                   null

End of function show_star_rating_review

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139 ms | 1009 KiB | 19 Q