3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* This is an untested re-scripting of Luis' posted snippet. * I am mostly avoiding single-use variables and separating "processing" from "displaying" portions of code * I am have added spaces when concatenating with dots, and between function parameters. * The addition of the head tags is only done if the option and view parameters are satisfactory. * Finally, it may be a good idea to call addcslashes($string, '"') on your variables for stability */ if (JRequest::getCmd('option') === "com_content" && JRequest::getCmd('view') === "article") { $doc =& JFactory::getDocument(); $article =& JTable::getInstance("content"); $article->load(strstr(JRequest::getString('id'), ':', true)); $twitterTitle = mb_strimwidth(strip_tags($article->get("title")), 0, 225, " ..."); $twitterDescription = mb_strimwidth(strip_tags($doc->getMetaData('description')), 0, 225, " ..."); $introImage = 'http://yourdomain.com/' . json_decode($article->get("images"))->image_intro; $doc->addCustomTag(' <meta name="twitter:title" content="{$twitterTitle}"/> <meta name="twitter:card" content="summary_large_image"/> <meta name="twitter:site" content="yoursite"/> <meta name="twitter:creator" content="yourcreator"/> <meta name="twitter:url" content="' . JURI::current() . '"/> <meta name="twitter:description" content="{$twitterDescription}"/> <meta name="twitter:image" content="{$introImage}"/> '); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 5, Position 2 = 10
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 71
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 71
Branch analysis from position: 10
filename:       /in/qvj0M
function name:  (null)
number of ops:  72
compiled vars:  !0 = $doc, !1 = $article, !2 = $twitterTitle, !3 = $twitterDescription, !4 = $introImage
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   INIT_STATIC_METHOD_CALL                                  'JRequest', 'getCmd'
          1        SEND_VAL_EX                                              'option'
          2        DO_FCALL                                      0  $5      
          3        IS_IDENTICAL                                     ~6      $5, 'com_content'
          4      > JMPZ_EX                                          ~6      ~6, ->10
          5    >   INIT_STATIC_METHOD_CALL                                  'JRequest', 'getCmd'
          6        SEND_VAL_EX                                              'view'
          7        DO_FCALL                                      0  $7      
          8        IS_IDENTICAL                                     ~8      $7, 'article'
          9        BOOL                                             ~6      ~8
         10    > > JMPZ                                                     ~6, ->71
   10    11    >   INIT_STATIC_METHOD_CALL                                  'JFactory', 'getDocument'
         12        DO_FCALL                                      0  $9      
         13        ASSIGN_REF                                               !0, $9
   11    14        INIT_STATIC_METHOD_CALL                                  'JTable', 'getInstance'
         15        SEND_VAL_EX                                              'content'
         16        DO_FCALL                                      0  $11     
         17        ASSIGN_REF                                               !1, $11
   12    18        INIT_METHOD_CALL                                         !1, 'load'
         19        INIT_FCALL                                               'strstr'
         20        INIT_STATIC_METHOD_CALL                                  'JRequest', 'getString'
         21        SEND_VAL_EX                                              'id'
         22        DO_FCALL                                      0  $13     
         23        SEND_VAR                                                 $13
         24        SEND_VAL                                                 '%3A'
         25        SEND_VAL                                                 <true>
         26        DO_ICALL                                         $14     
         27        SEND_VAR_NO_REF_EX                                       $14
         28        DO_FCALL                                      0          
   13    29        INIT_FCALL                                               'mb_strimwidth'
         30        INIT_FCALL                                               'strip_tags'
         31        INIT_METHOD_CALL                                         !1, 'get'
         32        SEND_VAL_EX                                              'title'
         33        DO_FCALL                                      0  $16     
         34        SEND_VAR                                                 $16
         35        DO_ICALL                                         $17     
         36        SEND_VAR                                                 $17
         37        SEND_VAL                                                 0
         38        SEND_VAL                                                 225
         39        SEND_VAL                                                 '+...'
         40        DO_ICALL                                         $18     
         41        ASSIGN                                                   !2, $18
   14    42        INIT_FCALL                                               'mb_strimwidth'
         43        INIT_FCALL                                               'strip_tags'
         44        INIT_METHOD_CALL                                         !0, 'getMetaData'
         45        SEND_VAL_EX                                              'description'
         46        DO_FCALL                                      0  $20     
         47        SEND_VAR                                                 $20
         48        DO_ICALL                                         $21     
         49        SEND_VAR                                                 $21
         50        SEND_VAL                                                 0
         51        SEND_VAL                                                 225
         52        SEND_VAL                                                 '+...'
         53        DO_ICALL                                         $22     
         54        ASSIGN                                                   !3, $22
   15    55        INIT_FCALL                                               'json_decode'
         56        INIT_METHOD_CALL                                         !1, 'get'
         57        SEND_VAL_EX                                              'images'
         58        DO_FCALL                                      0  $24     
         59        SEND_VAR                                                 $24
         60        DO_ICALL                                         $25     
         61        FETCH_OBJ_R                                      ~26     $25, 'image_intro'
         62        CONCAT                                           ~27     'http%3A%2F%2Fyourdomain.com%2F', ~26
         63        ASSIGN                                                   !4, ~27
   17    64        INIT_METHOD_CALL                                         !0, 'addCustomTag'
   22    65        INIT_STATIC_METHOD_CALL                                  'JURI', 'current'
         66        DO_FCALL                                      0  $29     
         67        CONCAT                                           ~30     '%0A++++++++%3Cmeta+name%3D%22twitter%3Atitle%22+++++++content%3D%22%7B%24twitterTitle%7D%22%2F%3E%0A++++++++%3Cmeta+name%3D%22twitter%3Acard%22++++++++content%3D%22summary_large_image%22%2F%3E%0A++++++++%3Cmeta+name%3D%22twitter%3Asite%22++++++++content%3D%22yoursite%22%2F%3E%0A++++++++%3Cmeta+name%3D%22twitter%3Acreator%22+++++content%3D%22yourcreator%22%2F%3E%0A++++++++%3Cmeta+name%3D%22twitter%3Aurl%22+++++++++content%3D%22', $29
         68        CONCAT                                           ~31     ~30, '%22%2F%3E%0A++++++++%3Cmeta+name%3D%22twitter%3Adescription%22+content%3D%22%7B%24twitterDescription%7D%22%2F%3E%0A++++++++%3Cmeta+name%3D%22twitter%3Aimage%22+++++++content%3D%22%7B%24introImage%7D%22%2F%3E%0A++++'
         69        SEND_VAL_EX                                              ~31
         70        DO_FCALL                                      0          
   26    71    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
177.27 ms | 1400 KiB | 21 Q