3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* Plugin Name: Weather Plugin Plugin URI: http://www.yourpluginurlhere.com/ Version: Current Version Author: Name please Description: What does your plugin do and what features does it offer... */ /** * Weather Plugin For Wordpress */ /** * Proper way to enqueue scripts and styles */ define('APFSURL', WP_PLUGIN_URL . "/" . dirname(plugin_basename(__FILE__))); function theme_name_scripts() { //define('weather-plugin', WP_PLUGIN_URL . "/" . dirname(plugin_basename(__FILE__))); wp_enqueue_style( 'weather-plugin', get_stylesheet_uri() ); wp_enqueue_script( 'weather-plugin',APFSURL.'/js/weather-plugin.js', array(), '1.0.0', true ); } add_action( 'wp_enqueue_scripts', 'theme_name_scripts' ); add_shortcode('weather-plugin','weather_function'); function weather_function(){ $ip = '203.135.41.33';//$_SERVER['REMOTE_ADDR']; $xml = new SimpleXMLElement(file_get_contents("http://www.geoplugin.net/xml.gp?={$ip}")); $city = (array)$xml->geoplugin_city; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22%27'.$city[0].'%27%2C%20ak%22)&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $weather_rss = curl_exec($ch); echo curl_error($ch); curl_close($ch); $return = json_decode($weather_rss); var_dump($weather_rss); $temp = $return->query->results->channel->item->condition->temp; echo "<div> Weather &nbsp; : &nbsp;"; echo "<div class = 'farenheit'> ".$temp." </div>"; $centi = 5/9*($temp-32); $centi1 = number_format((float)$centi, 0, '.', ''); echo "<div class = 'centigrade' style='display:none'> ".$centi1." </div>"; echo "<a hredf='#' id='btn1'>&nbsp;F</a> / <a href='#' id='btn2'> C</a>"; echo "</div>"; } ?>
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Fatal error: Uncaught Error: Undefined constant "WP_PLUGIN_URL" in /in/0NcJL:15 Stack trace: #0 {main} thrown in /in/0NcJL on line 15
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Fatal error: Uncaught Error: Undefined constant "WP_PLUGIN_URL" in /in/0NcJL:15 Stack trace: #0 {main} thrown in /in/0NcJL on line 15
Process exited with code 255.
Output for 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Warning: Use of undefined constant WP_PLUGIN_URL - assumed 'WP_PLUGIN_URL' (this will throw an Error in a future version of PHP) in /in/0NcJL on line 15 Fatal error: Uncaught Error: Call to undefined function plugin_basename() in /in/0NcJL:15 Stack trace: #0 {main} thrown in /in/0NcJL on line 15
Process exited with code 255.
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33
Fatal error: Uncaught Error: Call to undefined function plugin_basename() in /in/0NcJL:15 Stack trace: #0 {main} thrown in /in/0NcJL on line 15
Process exited with code 255.
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Fatal error: Call to undefined function plugin_basename() in /in/0NcJL on line 15
Process exited with code 255.

preferences:
306.17 ms | 402 KiB | 385 Q