We have a client with an older site that we haven't touched in a few years. The hosting provider is updating to PHP 7.3 mid september. From our test site there appears to be only one piece of code that needs to be updated for PHP 7.3. It's below and used to detect the initial path of the page the visitor is viewing, e.g. /educators/ or /parents/ etc. in order to display some special links in the navigation server side include.
http://domainname.com/educators/
http://domainname.com/educators/other-url-here/
http://domainname.com/parents/other-url-parts-here/
<?php
//GLOBAL PHP VARIABLES
//get current directory site path and change code links based off of that.
class dir {
function dir() {
$location = $_SERVER["SCRIPT_NAME"];
list($this->dir) = split("[a-zA-Z0-9_\-]*.php$", $location, 2);
}
}
$directory = new dir();
$sitepath = $directory->dir;
?>
The server error that comes back is this.... Fatal error: Uncaught Error: Call to undefined function split() in /nfs/c03/h03/mnt/46929/domains/domain-name-removed/html/includes/topnav_parents.php:9 Stack trace: #0 /nfs/c03/h03/mnt/46929/domains/domain-name-removed/html/includes/topnav_parents.php(12): dir->dir() #1 /nfs/c03/h03/mnt/46929/domains/domain-name-removed/html/parents/index.php(108): include('/nfs/c03/h03/mn...') #2 {main} thrown in /nfs/c03/h03/mnt/46929/domains/domain-name-removed/html/includes/topnav_parents.php on line 9 (I changed the site's domain name in the error message above domain-named-removed for client privacy)
We were using the $sitepath variable for some logic to display specific banner set blocks of content lower down in the footer section based on
if ($sitepath == "/parents/") we show one set or if the $sitepath == "/educators/" we display a different set.
If any of you PHP 7 guys know what the issue is, please advise. I would be most grateful. Thank you!