Created
May 27, 2023 13:35
-
-
Save denisdemaisbr/752bb0a47b2e0e26ab594f9c649f798f to your computer and use it in GitHub Desktop.
fix Got error 'PHP message: PHP Fatal error: Unparenthesized `a ? b : c ? d : e` is not supported. Use either `(a ? b : c) ? d : e` or `a ? b : (c ? d : e)` in public_html/system/helpers/url_helper.php on line 162'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
php -v | |
PHP 8.0.28 (cli) (built: Feb 14 2023 18:33:29) ( NTS ) | |
Copyright (c) The PHP Group | |
Zend Engine v4.0.28, Copyright (c) Zend Technologies | |
with Zend OPcache v8.0.28, Copyright (c), by Zend Technologies | |
grep CI_VERSION system/core/CodeIgniter.php | |
define('CI_VERSION', '3.0.0'); | |
*/ | |
// {{ your path }}/system/helpers/url_helper.php | |
if ( ! function_exists('anchor')) | |
{ | |
/** | |
* Anchor Link | |
* | |
* Creates an anchor based on the local URL. | |
* | |
* @param string the URL | |
* @param string the link title | |
* @param mixed any attributes | |
* @return string | |
*/ | |
function anchor($uri = '', $title = '', $attributes = '') | |
{ | |
$title = (string) $title; | |
// original code | |
// $site_url = is_array($uri) ? site_url($uri) : preg_match('#^(\w+:)?//#i', $uri) ? $uri : site_url($uri); | |
// fixed code | |
// https://github.com/bcit-ci/CodeIgniter/issues/3761 | |
// https://forum.codeigniter.com/thread-61352.html | |
$site_url = is_array($uri) ? site_url($uri) : ( preg_match('#^(\w+:)?//#i', $uri) ? $uri : site_url($uri) ); | |
if ($title === '') | |
{ | |
$title = $site_url; | |
} | |
if ($attributes !== '') | |
{ | |
$attributes = _stringify_attributes($attributes); | |
} | |
return '<a href="'.$site_url.'"'.$attributes.'>'.$title.'</a>'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment