Title: Broken Plugin, unexpected T_function
Last modified: August 20, 2016

---

# Broken Plugin, unexpected T_function

 *  Resolved [bouncebackdata1](https://wordpress.org/support/users/bouncebackdata1/)
 * (@bouncebackdata1)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/broken-plugin-unexpected-t_function/)
 * Hello,
    There is only one plugin I can find for an airport or flight school to
   display the current weather conditions and I would love to get it working. The
   developer seems to not exist anymore, so maybe someone on here can help. I get
   the following error whenever I try to activate the plugin: “Parse error: syntax
   error, unexpected T_FUNCTION in /home/content/63/8624163/html/wp-content/plugins/
   metar-widget/metar-widget.php on line 62” Line 62 is the last line. It’s a very
   simple plugin that uses a single php page. Here’s the entire code for the plugin:
 *     ```
       <?php
       /*
       Plugin Name: METAR plugin
       Plugin URI: http://wordpress.org/extend/plugins/metar-widget/
       Description: Plugin to include the latest METAR information from NOAA database for any Airport
       Version: 0.1
       Author: Luther Blissett
       Author URI: http://lutherblissett.net
       License: GPL3
       */
   
       class MetarWidget extends WP_Widget
       {
           public function __construct() {
               parent::__construct("metar_widget", "METAR Widget",
                   array("description" => "Plugin to inlclude the latest METAR information from NOAA database for any Airport"));
           }
   
           public function form($instance) {
               $icao = "";
               // if instance is defined, populate the fields
               if (!empty($instance)) {
                   $icao = $instance["icao"];
               }
   
               $tableId = $this->get_field_id("icao");
               $tableName = $this->get_field_name("icao");
               echo '<label for="' . $tableId . '">ICAO</label>';
               echo '<input id="' . $tableId . '" type="text" name="' .
                   $tableName . '" value="' . $icao . '"/>';
           }
   
           public function update($newInstance, $oldInstance) {
               $values = array();
               $values["icao"] = htmlentities($newInstance["icao"]);
               return $values;
           }
   
           public function widget($args, $instance) {
               $icao = $instance["icao"];
   
               $fileName = "http://weather.noaa.gov/pub/data/observations/metar/stations/$icao.TXT";
               $metar = '';
               $fileData = @file($fileName) or die('METAR not available');
               if ($fileData != false) {
               	list($i, $date) = each($fileData);
               	$utc = strtotime(trim($date));
               	$time = date("D, F jS Y g:i A",$utc);
   
               	while (list($i, $line) = each($fileData)) {
               		$metar .= ' ' . trim($line);
                   	}
               	$metar = trim(str_replace('  ', ' ', $metar));
               }
   
       	echo '<div class="widget widget-wrapper" id="' . $args['widget_id'] . '-container">';
       	echo '<div class="widget-title"><b>Current METAR for ' . $icao . '</b></div>';
       	echo $metar . '</div>';
           }
       }
   
       add_action("widgets_init", function () { register_widget("MetarWidget"); });
       ```
   
 * Any help is greatly appreciated,
    Mike

Viewing 15 replies - 1 through 15 (of 15 total)

 *  [Drew Jaynes](https://wordpress.org/support/users/drewapicture/)
 * (@drewapicture)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/broken-plugin-unexpected-t_function/#post-3134985)
 * Hi bouncebackdata1,
 * >> Please use [http://wordpress.pastebin.com](http://wordpress.pastebin.com) 
   if you’re going to post blocks of code in the forums.
 * I just activated it without issue on a WordPress 3.4.2. I also noticed the plugin
   page says it requires a minimum of version 3.4.
 * What version of WordPress are you running?
 *  Thread Starter [bouncebackdata1](https://wordpress.org/support/users/bouncebackdata1/)
 * (@bouncebackdata1)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/broken-plugin-unexpected-t_function/#post-3135000)
 * Hey, I’m running 3.4.2 as well. Is in conflicting with Jquery or something like
   that?
 *  Thread Starter [bouncebackdata1](https://wordpress.org/support/users/bouncebackdata1/)
 * (@bouncebackdata1)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/broken-plugin-unexpected-t_function/#post-3135001)
 * The site is [http://www.midwestrotor.com](http://www.midwestrotor.com)
 *  Thread Starter [bouncebackdata1](https://wordpress.org/support/users/bouncebackdata1/)
 * (@bouncebackdata1)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/broken-plugin-unexpected-t_function/#post-3135002)
 * I gave you _[mod redacted password]_ so you can take a look if you don’t mind.
   I tried changing line 62 a few times, it broke my site once and I had to go into
   the SQL database and disable all the plugins for the site to work again.
 *  [Rev. Voodoo](https://wordpress.org/support/users/rvoodoo/)
 * (@rvoodoo)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/broken-plugin-unexpected-t_function/#post-3135019)
 * _NOTE: Support given through this site is free and voluntary. As such, we usually
   do not want the burden/liability of being given access to a site. Even more so,
   PLEASE do not post unsolicited and public login credentials out in the open! 
   Kthx!_
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/broken-plugin-unexpected-t_function/#post-3135021)
 * How about PHP version? Anonymous functions are only supported with v5.3. If earlier,
   name the function and reference it in add_action().
 *  Thread Starter [bouncebackdata1](https://wordpress.org/support/users/bouncebackdata1/)
 * (@bouncebackdata1)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/broken-plugin-unexpected-t_function/#post-3135044)
 * I was running 5.2, but I upgraded to 5.3 and I get the same error. I’m using 
   the Karma theme, I’m guessing there must be some conflict with something in there.
   Anyone have any troubleshooting tips?
 *  Thread Starter [bouncebackdata1](https://wordpress.org/support/users/bouncebackdata1/)
 * (@bouncebackdata1)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/broken-plugin-unexpected-t_function/#post-3135045)
 * I just tried activating it on another karma theme site and I get the same error.
   I tried activating it on an avada theme site and it worked. I’m not sure how 
   to hunt down the problem.
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/broken-plugin-unexpected-t_function/#post-3135046)
 * You should probably still ditch the anonymous function for the sake of broader
   compatibility. That could get it working, you can worry about why anonymous functions
   aren’t working later.
 *  Thread Starter [bouncebackdata1](https://wordpress.org/support/users/bouncebackdata1/)
 * (@bouncebackdata1)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/broken-plugin-unexpected-t_function/#post-3135049)
 * How do I do that?
 *  Thread Starter [bouncebackdata1](https://wordpress.org/support/users/bouncebackdata1/)
 * (@bouncebackdata1)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/broken-plugin-unexpected-t_function/#post-3135052)
 * I’m sorry, I don’t know a lot about programming, but I can usually figure things
   out with some direction.
 *  Thread Starter [bouncebackdata1](https://wordpress.org/support/users/bouncebackdata1/)
 * (@bouncebackdata1)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/broken-plugin-unexpected-t_function/#post-3135065)
 * Can anyone tell me how to “ditch the anonymous function”?
 *  [alieneila](https://wordpress.org/support/users/alieneila/)
 * (@alieneila)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/broken-plugin-unexpected-t_function/#post-3135066)
 * The last line of your code…
 * add_action(“widgets_init”, function () { register_widget(“MetarWidget”); });
 * see the “function () {}” that is an anonymous function, it’s not named.
 * try using…
 * add_action( ‘widgets_init’, create_function( ”, ‘register_widget( “MetarWidget”);’));
 *  Thread Starter [bouncebackdata1](https://wordpress.org/support/users/bouncebackdata1/)
 * (@bouncebackdata1)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/broken-plugin-unexpected-t_function/#post-3135067)
 * Finally! it works! Thank you very much for the help.
 *  [alieneila](https://wordpress.org/support/users/alieneila/)
 * (@alieneila)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/broken-plugin-unexpected-t_function/#post-3135068)
 * you’re quite welcome =)

Viewing 15 replies - 1 through 15 (of 15 total)

The topic ‘Broken Plugin, unexpected T_function’ is closed to new replies.

## Tags

 * [unexpected T_function](https://wordpress.org/support/topic-tag/unexpected-t_function/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 15 replies
 * 5 participants
 * Last reply from: [alieneila](https://wordpress.org/support/users/alieneila/)
 * Last activity: [13 years, 7 months ago](https://wordpress.org/support/topic/broken-plugin-unexpected-t_function/#post-3135068)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
