Scriptcase 9.8 - Functions deprecated and/or alterated in PHP 8.1

Scriptcase 9.8 - Functions deprecated and/or alterated in PHP 8.1

One of the features of the new version is the possibility to generate applications that are compatible with PHP 8 and 8.1.
This way, users that are using Scriptcase 9.8 will be able to make deployments in environments with its PHP updated (versions 8 and 8.1), regardless of the PHP used when installing Scriptcase.

With this implementation, some code used in events or libraries of your applications may stop working, due to the deprecated or removed functions in the newest versions of PHP.
It's the developer's responsibility to correct errors resulting from this incompatibility with the codes used in events or libraries.

Bellow, there's a list of some functions that will stop working or have their functioning changed in PHP 8.1.

To have the complete list of the changes in PHP, here follow the links according to each version.


Ternary operators nested without explicit parentheses

Nested ternary operations must explicitly use parentheses to dictate the order of the operations.

Example
Code before PHP 8:
  1. 1 ? 2 : 3 ? 4 : 5;   //This way is now deprecated
Code in PHP 8 or superior:
  1. (1 ? 2 : 3) ? 4 : 5; //Using parentheses to dictate the order of the operations

Array and string offset access using curly braces

The array and string offset access syntax using curly braces are deprecated. Use $var[$idx] instead of $var{$idx}.
In PHP 8.1 if you use curly braces { } to recover values in an array you'll obtain an error.

This PHP change may cause an error in Security Module generated in previous versions. See article Scriptcase 9.8 - Fatal error: Array and string offset in Security Module

Example
Code before PHP 8:
  1. $code .= $chars{mt_rand(0$max)};
Code in PHP 8 or superior:
  1.  $code .= $chars[mt_rand(0$max)];

Variables containing a null value

Up until PHP 7, it was possible to do mathematical operations with variables containing values of type null, which was the equivalent to zero.
In PHP 8.1 this kind of operation started to present errors.

Example
Code before PHP 8:
  1. $tst_null = null;
  2. $xx = 1;
  3. $result = $tst_null + $xx;
  4. $result wil be equal to 1
Code in PHP 8 or superior:
  1. $tst_null = null;
  2. $xx = 1;
  3. $result = $tst_null + $xx;
  4. An error will appear

Function each()

Return the current key and value pair from an array and advance the array cursor.
This function has been deprecated as of PHP 7.2.0 and removed as of PHP 8. If this function is being used in an application, then the code must be altered before deploying the application in an environment with PHP 8 or superior.

Some alternative functions:

Function array_key_exists()

Checks if the given key or index exists in the array.
This function's use in objects is deprecated, so in its place should be used the functions isset() or property_exists().

Function money_format()

Formats a number as a currency string.
This function has been deprecated as of PHP 7.4.0 and removed as of PHP 8, but it could be replaced by the functionality intl NumberFormatter.

Function convert_cyr_string()

Convert from one Cyrillic character set to another.
This function is no longer available as of PHP 8, in its place, there are other functions that can be used like: mb_convert_string(), iconv() or UConverter

Function mb_strrpos()

Find the position of the last occurrence of a string in a string.
Passing the encoding as the third argument instead of an offset has been removed.

Instead, pass an offset 0 and the encoding as the fourth parameter.
Example:
  1. mb_strrpos(
  2.         string $haystack,
  3.         string $needle,
  4.         int $offset = 0,
  5.         ?string $encoding = null
  6. ):

    • Related Articles

    • PHP functions necessary for ScriptCase

      In PHP , there are some essential functions for the operation of Scriptcase .  On some servers , these functions are disabled , this makes the Scriptcase not work properly.  If you're using a shared hosting server, you'll need to contact the host ...
    • Updating Scriptcase's PHP

      Currently, the installation of Scriptcase 9.x comes with version 7.0.14 of PHP, unfortunately, this version has a compatibility problem with the new version of authentication of MySQL 8.0, so it is necessary to perform the PHP update so the ...
    • Installing PHP 7.0 - Windows

      This article explains PHP 7.0 and Apache 2.4 installation to ScriptCase use. Supported Operating Systems: Windows Server 2008 SP2 2008 R2 SP1 2012 2012 SP2 2016 Windows 7 SP1 Vista SP2 8 8.1 10 Necessary Files: PHP 7.0: Click Here Apache 2.4: Click ...
    • Installing PHP 7.0 - Linux

      This article describes PHP 7.0 and Apache 2.4 installation to ScriptCase use. Supported Operating Systems: Ubuntu Debian CentOS\RHEL OpenSuse Necessary Files: SourceGuardian Loader (ixed.7.0.lin): Click Here Setting Up PHP - Ubuntu Because of recent ...
    • New features in PHP 8.1

      With the launching of Scriptcase 9.8 your projects can be deployed in an updated environment, with the PHP 8 or 8.1. Kind reminder that it is still possible to make deployment in environments with outdated PHP, since it's compatible with PHP 5.6 or ...
    • Popular Articles

    • Examples for diagrams

      This tutorial shows how you can import and use the new examples for diagrams released with Scriptpcase V9.2.16.  The applications were created using the components: Jsmind, JKanban e Orgchart.  - Sample 1: Mind Map diagram Click here to  execute the ...
    • Manual Update - Windows

      Before performing any procedure we recommend performing a backup of your projects. To back up Scriptcase: Go to Settings > Administration, in the side menu go to Services > Backup. A file (.ZIP) will be generated with all your projects, save this ...
    • PHP functions necessary for ScriptCase

      In PHP , there are some essential functions for the operation of Scriptcase .  On some servers , these functions are disabled , this makes the Scriptcase not work properly.  If you're using a shared hosting server, you'll need to contact the host ...
    • Oracle Connection - Scriptcase 9 - Linux 64 Bits

      This procedure will only work if you have a Scriptcase manual installation in your server. Installing PHP 7.0 Installing the Scriptcase Manually To connect with Oracle in a Linux System, we must follow these steps below: Step 1 -  Installing these ...
    • Using friendly URL

      The friendly URL was included from Scriptcase 7, in order to make the URL, of the applications generated by Scriptcase, cleaner and easier to associate them with applications. For example, using friendly URLs the link to a Scriptcase application ...