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}"/> '); }
based on s24QL
Output for 8.0.0 - 8.0.2
Fatal error: Uncaught Error: Class "JRequest" not found in /in/qvj0M:9 Stack trace: #0 {main} thrown in /in/qvj0M on line 9
Process exited with code 255.
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.26, 7.4.0 - 7.4.13
Fatal error: Uncaught Error: Class 'JRequest' not found in /in/qvj0M:9 Stack trace: #0 {main} thrown in /in/qvj0M on line 9
Process exited with code 255.