Parse error: syntax error, unexpected 'exit' (T_EXIT) line 1 - php

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'
));

Related

How do I declare a public function in Laravel 8 Base Controller

am getting the following syntax error, unexpected 'public' (T_PUBLIC), expecting end of file when running this code from Microsoft PHP Graph Tutorial.
(https://learn.microsoft.com/en-us/graph/tutorials/php?tutorial-step=1)
public function loadViewData(){
$viewData = [];
// Check for flash errors
if (session('error')) {
$viewData['error'] = session('error');
$viewData['errorDetail'] = session('errorDetail');
}
// Check for logged on user
if (session('userName')) {
$viewData['userName'] = session('userName');
$viewData['userEmail'] = session('userEmail');
$viewData['userTimeZone'] = session('userTimeZone');
}
return $viewData;
}
( I am relatively inexperienced php person, trying to learn laravel and link to Microsoft Graph. There are many tutorials for linking to Microsoft but none of them work as far as I can see, most are out of date. This was my best hope.
Code not working: note line below is one causing problem. If remove 'public;' then no errors are reported in VSCode
i.e. Note in VSCode it reports no errors in the file if public is removed. As soon as you add it back in you get '
As per the the code is correct but you need to check the class of curly brackets properly close or not .
1 ) when you are using the class and no closing curly brackets properly that time it's given error like unexpected 'public' (T_PUBLIC), expecting end of file .
class yourController extends Controller {
public function loadViewData(){
$viewData = [];
// Check for flash errors
if (session('error')) {
$viewData['error'] = session('error');
$viewData['errorDetail'] = session('errorDetail');
}
// Check for logged on user
if (session('userName')) {
$viewData['userName'] = session('userName');
$viewData['userEmail'] = session('userEmail');
$viewData['userTimeZone'] = session('userTimeZone');
}
return $viewData;
}
}

How do I solve this laravel layout issue?

My error: I am facing this issue quite long time and found one solution in stackoverflow but it doesn't work. I need solution to work with laravel , php 7+ and mysql.
It is showing below error:
ErrorException
Trying to get property 'app_layout' of non-object
Error page consists following code and i tried all solutions in stack overflow but no us. I want to show my layout without any error here.
Error in the script\app\Http\Controllers\MainBaseController.php:26
code on the page is : error line highlighted in BOLD below
use Illuminate\Support\Facades\Schema;
use Froiden\Envato\Traits\AppBoot;
class MainBaseController extends Controller
{
public function __construct()
{
parent::__construct();
// Settings
$this->settings = Setting::first();
$this->year = Common::year();
$this->bootstrapModalRight = true;
$this->bootstrapModalSize = 'md';
**$this->siteLayout = $this->settings->app_layout; // top, sidebar**
$this->forbiddenErrorView = 'errors.403';
$this->showFooter = true;
$this->rtl = $this->settings->rtl;
// Status
$this->statusArray = [
'enabled' => __('app.enabled'),
'disabled' => __('app.disabled')
];
// Setting assets path
$allPaths = Common::getFolderPath();
foreach($allPaths as $allPathKey => $allPath)
{
$this->{$allPathKey} = $allPath;
I am placing error part of the code above , if you need any other parts i will provide

Fatal Error On Zend Project Live On Server Random

I have a Zend2 project running on my localhost with no problems. The app runs perfect. I Uploaded it to my server and now it gets a fatal error but not every time.
Sometimes it says this,
Fatal error: Class name must be a valid object or a string in /home/public_html/vendor/zendframework/zend-stdlib/src/ArrayObject.php on line 230
public function getIterator()
{
$class = $this->iteratorClass;
return new $class($this->storage); // line 230
}
And sometimes it says this,
File
/vendor/zendframework/zend-stdlib/src/ArrayObject.php:184
Message:
Passed variable is not an array or object, using empty array instead
Never both and sometimes it loads perfectly with no problems. The file it references is in the vendor path this is the link,
public function exchangeArray($data)
{
if (!is_array($data) && !is_object($data)) {
throw new Exception\InvalidArgumentException('Passed variable is not an array or object, using empty array instead');
} // Line 184
if (is_object($data) && ($data instanceof self || $data instanceof \ArrayObject)) {
$data = $data->getArrayCopy();
}
if (!is_array($data)) {
$data = (array) $data;
}
$storage = $this->storage;
$this->storage = $data;
return $storage;
}
Any ideas why this would happen on a live server with a zend site but not on a localhost?
I found this post on github which I think it related to ZFCUser
Git Hub Post
Someone in the comments says this,
This issue is caused by the layout.phtml when there is an error. The layout needs to render but it doesn't have $this->url
I have no clue what he is talking about. Is anyone able to shoot me in the right direction?

Fatal error: Cannot use [] for reading

I'm getting this error
Fatal error: Cannot use [] for reading in... on line 26
Checking all the threads that have been made here on this error, I still cannot figure it out. Looking at my code there's nothing I'm doing wrong.
<?php
class Person
{
//Variables for personal information//
private $navn;
private $adresse;
private $postnummer;
private $poststed;
private $telefonnummer;
private $fodselsdato;
public function __construct($navn, $adresse, $postnummer, $poststed, $telefonnummer, $fodselsdato)
{
$this->navn = $navn;
$this->adresse = $adresse;
$this->postnummer = $postnummer;
$this->poststed = $poststed;
$this->telefonnummer = $telefonnummer;
$this->fodselsdato = $fodselsdato;
}
//Creates an array to store education for a person//
private $utdanning = array();
//Function to add education to the array//
public function leggTilUtdanning(Utdanning $utdanning)
{
$this->utdanning[] = $utdanning;
}
}
//Class for education
class Utdanning
{
private $institusjon;
private $studieretning;
private $grad;
private $startet;
private $ferdig;
public function __construct($institusjon, $studieretning, $grad, $startet, $ferdig)
{
$this->institusjon = $institusjon;
$this->studieretning = $studieretning;
$this->grad = $grad;
$this->startet = $startet;
$this->ferdig = $ferdig;
}
}
$person1 = new Person('Dave Lewis', 'Downing Street 14', 0442, 'Northville', 98765432, '17.05.1975');
$utdanning = new Utdanning('Harvard', 'Economics', 'Bachelor', 2013, 2016);
$person1->leggTilUtdanning($utdanning);
?>
The error comes from the line inside the function where I'm trying to add an Utdanning-object to the array. It's funny, cause I tried this very same method of doing it on another project, using the exact same syntax, and it worked perfectly. Furthermore, I don't understand why it says I'm trying to read from the array, when I'm actually adding to it.
Does anyone have an idea what's going on here?
EDIT: I circled the problem and made a more simple version of the code so you can see for yourself.
So, just to mark this solved, I got rid of the problem simply by rewriting the characters inside the method leggtilUtdanning. Appears to have been some sort of character encoding-problem like you pointed out, but I have absolutely no idea how that happened. Anyway, thanks for all the help.

Getting an Unexpected T_Function Error and I don

This may be a dumb question. I am getting an unexpected T_ERROR for the following code in my WordPress Functions.php file. This happens often and I review the code several times seeing no problems... So I've decided to ask someone why.
Thank you.
<?php
/*
**Remove WordPress 'w'
*/
function annointed_admin_bar_remove() {
global $wp_admin_bar;
/* Remove their stuff */
$wp_admin_bar->remove_menu('wp-logo');
}
add_action('wp_before_admin_bar_render', 'annointed_admin_bar_remove', 0);
/*
** Remove WordPress Dashboard Widgets
*/
function remove_dashboard_widgets() {
global $wp_meta_boxes;
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_drafts']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);
}
add_action('wp_dashboard_setup', 'remove_dashboard_widgets' );
?>

Categories