php - SymfonyComponentDebugExceptionFatalThrowableError : syntax error, unexpected end of file
one text
Solution:
This is due to the use of endif
keyword that marks the end of an if
statement that was started with syntax containing colon like so
if(...):
//..
elseif:
//..
else:
//..
endif;
However since you are using curly braces, the use of endif
at the end of the condition block is incorrect syntax hence the syntax error
To fix this error, simply reemove the endif
keyword from your code:
<?php
function extView($route)
{
$texts = [];
$mercati = ['banking-finance-fintech', 'insurance-insurtech', 'consumer-goods', 'industrial-goods', 'energy-utilities-infrastructure', 'luxury-fashion-design', 'sport-media-entertainment', 'pharma-medicine-healthcare', 'technology-telecom', 'public-sector', 'social-sector', 'private-equity'];
$servizi = ['strategy-governance', 'competitive-intelligence', 'innovation-management', 'ai-bigdata', 'marketing', 'sponsorship', 'sales', 'brand-communication', 'hr-organization', 'sustainability', 'ma'];
if (array_key_exists($route, $texts)) {
return view('general-list', {$texts[$route]});
} else if (in_array($route, $mercati)) {
return view('general-list', {$texts['banking-finance-fintech']});
} else if (in_array($route, $servizi)) {
return view('general-list', {$texts['sponsorship']});
} else {
abort(404);
}
// dont use endif here
}
?>
Source