chiranjiv Posted January 7, 2016 Share Posted January 7, 2016 Hi, I'm new to this forum so not so sure if I'm posting in the right place or about the full rules and regulations of the forum system, so if I've got something wrong please redirect me and let me know. Basically, I'm receiving a parse error when trying to go onto our website - I had tried restoring my website from an old backup and now it's giving me this error: Parse error: syntax error, unexpected 'exit' (T_EXIT) in /home/cdchk/domains/dev.cdchk.org/public_html/wp-content/plugins/woocommerce-catalog/include/php/settings.php on line 1 I tried looking into this file (settings.php under the WooCommerce Catalog Plugin files), but am lost as to what the error is. I will post the first section of the code below. Let me know if there's an issue. Thanks. <?php if (!defined('ABSPATH')) exit; class Woo_Catalog_Settings { private $dir; private $file; private $assets_dir; private $assets_url; private $settings_base; private $settings; public function __construct($file) { $this->file = $file; $this->dir = dirname($this->file); $this->assets_dir = trailingslashit($this->dir) . 'include'; $this->assets_url = esc_url(trailingslashit(plugins_url('/include/', $this->file))); $this->settings_base = 'woo_Catalog_'; // Initialise settings add_action('admin_init', array( $this, 'init' )); // Register plugin settings add_action('admin_init', array( $this, 'register_settings' )); // Add settings page to menu add_action('admin_menu', array( $this, 'add_menu_item' )); // Add settings link to plugins page add_filter('plugin_action_links_' . plugin_basename($this->file) , array( $this, 'add_settings_link' )); } /** * Initialise settings * @return void */ public function init() { $this->settings = $this->settings_fields(); } Quote Link to comment https://forums.phpfreaks.com/topic/300211-parse-error-syntax-error-unexpected-exit-t_exit/ Share on other sites More sharing options...
benanamen Posted January 7, 2016 Share Posted January 7, 2016 (edited) Try this: if (!defined('ABSPATH')) {exit;} Edited January 7, 2016 by benanamen Quote Link to comment https://forums.phpfreaks.com/topic/300211-parse-error-syntax-error-unexpected-exit-t_exit/#findComment-1529229 Share on other sites More sharing options...
ginerjm Posted January 7, 2016 Share Posted January 7, 2016 Actually the braces are not required for this usage of the if statement. As I said in a different forum, try adding the parens to the exit call. Quote Link to comment https://forums.phpfreaks.com/topic/300211-parse-error-syntax-error-unexpected-exit-t_exit/#findComment-1529241 Share on other sites More sharing options...
mac_gyver Posted January 7, 2016 Share Posted January 7, 2016 neither the {} around the exit or () on the end of exit are required, nor does the lack of them throw a syntax error. since the error gives line 1 as where the problem is being detected at and there's no statement on line 1, either this isn't the actual code the error is referring to or there's something going on with the file's character encoding or a broken php installation that's causing the problem. Quote Link to comment https://forums.phpfreaks.com/topic/300211-parse-error-syntax-error-unexpected-exit-t_exit/#findComment-1529243 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.