Code Event Listener Problem - Fatal Error

I'm trying to include a PHP header in my forum so that it's consistent with my site. On my main PHP site I have a 100% width header that goes across the top.

I've been following a post in this thread which explains how to do exactly that with template hooks:

I've put my forum into debug mode and have created a new plugin called "AUSFIFA Header". I've created a directory for my plugin and created a class inside of it:


AFHeader.php looks like this:
class AUSFIFA_AFHeader_AFHeader
  public static function includePhpFile($hookName, &$contents, array $hookParams, XenForo_Template_Abstract $template)
  if($hookName == 'af_header')
  $contents .= ob_get_contents();
My problem occurs when I go to add a new Code Event Listener.

I specify it to listen to event "Template Hook". And then in Execute Callback I write:
AUSFIFA_AFHeader_AFHeader :: includePhpFile

I leave everything else blank.

I click "Save Event Listener" and I get an error message stating:
"The server responded with an error. The error message is in the JavaScript console.".

I check the Server Error Log and I'm getting this Fatal Error:
Error Info
ErrorException: Fatal Error: syntax error, unexpected T_STRING - library/AUSFIFA/AFHeader/AFHeader.php:1
Generated By: Kani, 3 minutes ago

Stack Trace
#0 [internal function]: XenForo_Application::handleFatalError()
#1 {main}

Request State
array(3) {
["url"] => string(65) ""
["_GET"] => array(1) {
["code-event-listeners/save"] => string(0) ""
["_POST"] => array(13) {
["event_id"] => string(13) "template_hook"
["hint"] => string(0) ""
["callback_class"] => string(25) "AUSFIFA_AFHeader_AFHeader"
["callback_method"] => string(14) "includePhpFile"
["execute_order"] => string(2) "10"
["active"] => string(1) "1"
["description"] => string(0) ""
["addon_id"] => string(0) ""
["event_listener_id"] => string(1) "0"
["_xfToken"] => string(8) "********"
["_xfRequestUri"] => string(42) "/forums/admin.php?code-event-listeners/add"
["_xfNoRedirect"] => string(1) "1"
["_xfResponseType"] => string(4) "json"
Why is this happening? Am I missing something?

Chris D

XenForo developer
Staff member
According to the error there seems to be a syntax problem on line 1.

The code looks ok. Therefore this could be indicative of the file being corrupted in some way.

What editor did you use to create the file? If you edit the file in another editor make sure there are no stray characters or characters that have been encoded in an odd way.

The only thing is if the file you're including has a syntax error but you will be able to test that easily enough.