PHP Classes

PHP Backwards Compatibility Library: Functions of newer PHP versions for older versions

Recommend this page to a friend!
  Info   Example   Demos   Screenshots   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2025-02-22 (8 hours ago) RSS 2.0 feedNot yet rated by the usersTotal: 94 All time: 9,892 This week: 46Up
Version License PHP version Categories
phpbcl 2.0.3Custom (specified...5.6PHP 5, Language
Description 

Author

This package provides functions of newer PHP versions for older versions.

It provides scripts that implement functions only available in newer PHP versions as functions built-in in the PHP core engine. The parts work in older PHP versions.

A main script checks the current PHP version and loads that implement the functions of newer PHP versions.

Innovation Award
PHP Programming Innovation award nominee
June 2023
Number 2
With every new PHP version, changes are made to the PHP language that may introduce incompatibilities between versions.

If your PHP applications rely on parts of the language that were changed, you may need to change your code to keep it working in the new PHP version that runs on the machine your PHP application is running.

Suppose your PHP application relies on PHP function or other parts of the language that changed in a backward incompatibility way. In that case, you may need to change your PHP application code to adapt to the PHP version changes.

This package provides a library of scripts with PHP functions that emulate the functions introduced in newer PHP versions.

Using this library, you can adapt your PHP application code to make it work in a newer PHP version without having to upgrade the PHP version that you use in the environment your PHP application is running.

This way, you can change your PHP application code to prepare to make it work in newer PHP versions making a smooth transition between PHP versions.

Manuel Lemos
Picture of ASCOOS CMS
  Performance   Level  
Innovation award
Innovation award
Nominee: 15x

Winner: 1x

 

Instructions

Installation and use this library

  1. Download latest release
  2. Unzip package in your working directory
  3. Add in index.php or master php file the below code :

$path = '[YOUR SITE PATH]';

include $path . '/phpBCL/autoload.php';

Example

<?php
/**
 * __ _ ___ ___ ___ ___ ___ ____ _ __ ___ ___
 * / _` |/ / / __/ _ \ / _ \ / / / __/| '_ ` _ \ / /
 * | (_| |\ \| (_| (_) | (_) |\ \ | (__ | | | | | |\ \
 * \__,_|/__/ \___\___/ \___/ /__/ \___\|_| |_| |_|/__/
 *
 *
 *************************************************************************************
 * @ASCOOS-NAME : ASCOOS CMS 24' *
 * @ASCOOS-VERSION : 24.0.0 *
 * @ASCOOS-CATEGORY : Kernel (Frontend and Administration Side) *
 * @ASCOOS-CREATOR : Drogidis Christos *
 * @ASCOOS-SITE : www.ascoos.com *
 * @ASCOOS-LICENSE : [Commercial] http://docs.ascoos.com/lics/ascoos/AGL-F.html *
 * @ASCOOS-COPYRIGHT : Copyright (c) 2007 - 2024, AlexSoft Software. *
 *************************************************************************************
 *
 * @package : ASCOOS CMS - phpBCL
 * @subpackage : Example PHP_BUILD_DATE Constant
 * @source : /phpBCL/test/85_php_build_date.php
 * @version : 2.0.0
 * @created : 2024-11-29 07:00:00 UTC+3
 * @updated :
 * @author : Drogidis Christos
 * @authorSite : www.alexsoft.gr
 *
 * @since 2.0.0
 * @since PHP 5.6.40
 */

require_once("../autoload.php");

$dt = DateTimeImmutable::createFromFormat('M j Y H:i:s', PHP_BUILD_DATE);

$dt1 = $dt->format('U')."<br>"; // Unix timestamp, e.g. "1758019466"
$dt2 = $dt->format('Y-M-d')."<br>"; // "2025-Sep-16"
?>
<html>
<head>
    <style>
        h1 {font-size: 2em; font-weight: bold; width: 100% !important; }
        h2 {font-size: 1.5em; font-weight: bold; padding: 5px; color: white; background-color: black; width: 100% !important; margin: 4px 0;}
    </style>
</head>
<body>
<?php
echo '<h1>PHP VERSION: '.phpversion().'</h1>';
echo
'<h2>TEST PHP 8.5 [ <b>PHP_BUILD_DATE</b> ] </h2>';
echo
'<p><br></p>';

echo
'<p><b>PHP_BUILD_DATE [Unix timestamp (U)]....:</b> '.$dt1.'</p>';
echo
'<p><b>PHP_BUILD_DATE [Date (Y-M-d)]..........:</b> '.$dt2.'</p>';

?>
</body>
</html>


Details

Changelog

2.0.2 [2024-12-08]

phpBCL Core and Examples

  • Updated autoload.php

2.0.1 [2024-12-01]

phpBCL Core and Examples

  • Fixed composer.json file
  • Fixed libin.json file

2.0.0 [2024-11-29]

phpBCL Core and Examples

  • Added support for LibIN Installer
  • Added support for PHPClasses composer installer

PHP < 8.5

CONSTANTS

  • Added dynamic Constant `PHP_BUILD_DATE` : that is assigned the time and date the PHP binary is built.

EXAMPLES

  • Added example file `85_php_build_date.php` :

1.1.4 [2024-11-12]

PHP < 8.4

  • Added Function `intltz_get_iana_id` -- Get the IANA identifier from a given timezone
  • ADDED EXAMPLE FILE : `84_intltz_get_iana_id.php`
  • UPDATED EXAMPLE FILE : `84_grapheme_str_split.php`

1.1.3 [2024-10-22]

PHP < 8.4

  • Fixed Function `bcdivmod` for use in PHP < 7.2.0

phpBCL Core and Examples

  • The examples have been changed to adapt to the new structure of the package.
  • Removed some source code from all files to make it more accessible to use of the package.

    // Run only Ascoos Cms
    define( 'ALEXSOFT_RUN_CMS', true ); //REMOVED
    

    and

// $cms_path is Ascoos Cms global variable
require_once($cms_path."/phpBCL/src/coreCompatibilities.php"); // REMOVED

They have been replaced with the internal variable $phpCBL of the package, which you do not need to call.

>You should load only the file autoload.php file into your code.

$path = '[YOUR SITE PATH]';
include $path . '/phpBCL/autoload.php'; / // For general use

OR

include '../autoload.php'; // Used by phpBCL examples

1.1.2 [2024-10-04]

  • Updated README.md

PHP < 8.4

  • Added Function `bcdivmod`
  • ADDED EXAMPLE FILE : `84_bcdivmod.php`
  • ADDED EXAMPLE FILE : `84_array_find.php`
  • ADDED EXAMPLE FILE : `84_array_find_key.php`
  • ADDED EXAMPLE FILE : `84_array_all.php`
  • ADDED EXAMPLE FILE : `84_array_any.php`
  • ADDED EXAMPLE FILE : `84_grapheme_str_split.php`

*

1.1.1 [2024-09-23]

  • Updated README.md

PHP < 8.4

  • Added Function `array_find`
  • Added Function `array_find_key`
  • Added Function `array_all`
  • Added Function `array_any`
  • Added Function `grapheme_str_split`

*

1.1.0 [2024-03-20]

  • Updated README.md
  • ADDED FILE : `LICENSE_AGL-F.md` -- Package License `AGL-F` (Ascoos General License - Free Use).
  • ADDED EXAMPLE FILE : `84__http_get_last_response_headers.php`

PHP < 8.4

  • Added Function `http_get_last_response_headers`
  • Added Function `http_clear_last_response_headers`
  • UPDATED FUNCTIONS : `mb_trim`, `mb_ltrim`, `mbrtrim`

*

1.0.9 [2024-02-28]

PHP < 8.3.0

  • Added Function `stream_context_set_options` -- Sets options on the specified context.

PHP < 8.2.0

  • Added Function `openssl_cipher_key_length` -- Gets the cipher key length.

PHP < 8.0.0

  • Added Function `preg_last_error_msg` -- Returns the error message of the last PCRE regex execution.
  • Added Function `get_debug_type` -- Returns the resolved name of the PHP variable value.
  • Added Function `get_resource_id` -- Returns an integer identifier for the given resource
  • Added Function `fdiv` -- Divides two numbers, according to IEEE 754

PHP < 7.1.0

  • Added Function `openssl_get_curve_names` -- Gets the list of available curve names

PHP < 7.0.0

  • Added Function `intdiv` -- Integer division

SIMILAR

  • Added Function `alf_get_class()` -- For return getClass() without parameters on PHP >= 8.3.0

*

1.0.8 [2024-02-27]

  • ADDED FILE : compat_error.php
  • Added Class Error `Error`
  • Added Class Error `TypeError`
  • Added Class Error `ValueError`

PHP < 8.2.0

  • Added Function `ini_parse_quantity`
  • FIXED FUNCTION : `mysqli_execute_query`

*

1.0.7 [2024-02-22]

PHP < 8.4.0

  • Added phpBCL Function `alf_preg_quote`
  • FIXED FUNCTIONS : `mb_trim`, `mb_ltrim`, `mbrtrim` for use on PHP 5.6
  • FIXED EXAMPLE : `84__mb_trim.php`
  • ADDED SCREENSHOTS

*

1.0.6 [2024-02-21]

  • FIXED EXAMPLE : `81__array_is_list.php`
  • FIXED EXAMPLE : `84_mb_ucfirst.php`
  • ADDED SCREENSHOTS

*

1.0.5 [2024-02-20]

PHP < 8.4.0

  • ADDED FILE: `/src/phpBCL.php`
  • Added phpBCL Function `validate_encoding`
  • Added Function `mb_ltrim`
  • Added Function `mb_rtrim`
  • Added Function `mb_trim`
  • ADDED EXAMPLE: `/test/84__mb_trim.php`
  • Updated Function `mb_ucfirst`
  • Updated Function `mb_lcfirst`
  • Updated Example `/test/84__mb_ucfirst.php`

*

1.0.4 [2024-02-17]

PHP < 8.4.0

  • Added file `src/compat/compat_php84x.php`
  • Added Function `mb_ucfirst`
  • Added Function `mb_lcfirst`
  • ADDED EXAMPLE: `/test/84__mb_ucfirst.php`

*

1.0.3 [2023-07-12]

PHP < 8.2.0

  • Added Function `mysqli_execute_query`

*

1.0.2 [2023-07-07]

  • ADDED EXAMPLES: In folder /phpBCL/test/
  • Fixed : Fixed paths for call phpBCL library.

PHP < 4.3.0

  • Added Constants: `MB_CASE_UPPER`, `MB_CASE_LOWER`, `MB_CASE_TITLE`
  • Added Function: `mb_convert_case`

PHP < 5.5.0

  • Added Functions: `array_column`, `boolval`, `json_last_error_msg`

PHP < 7.3.0

  • Added Constants: `MB_CASE_FOLD`, `MB_CASE_UPPER_SIMPLE`, `MB_CASE_LOWER_SIMPLE`, `MB_CASE_TITLE_SIMPLE`, `MB_CASE_FOLD_SIMPLE`. Used by ASCOOS LIBRARY FUNCTION `alf_mb_convert_case` (compat_similar.php)
  • Updated Functions: `array_key_first`, `array_key_last`
ASCOOS LIBRARY FUNCTION:
  • Added `alf_mb_convert_case` For full compatible similar mb_convert_case.

PHP < 7.4.0

  • Added Function: `mb_str_split`

PHP < 8.0.0

  • Updated Functions: `str_contains`, `str_ends_with`, `str_starts_with`
  • Updated Classes : `Stringable`, `PhpToken`

PHP < 8.1.0

  • Updated Function: `array_is_list`

PHP < 8.3.0

  • Added Function: `mb_str_pad`

*

1.0.1 [2023-06-27]

  • Added file compat_similar.php (for similar functions)

PHP < 7.1.0

  • Added Function: `is_iterable`

PHP < 7.3.0

  • Added Functions: `array_key_first`, `array_key_last`, `is_countable`

PHP < 8.0.0

  • Added Class `ValueError` (For php < 8.0.0)

*

1.0.0

  • Creating Compatibilities

  8.4 grapheme_str_splitExternal page   8.4 intltz_get_iana_idExternal page   8.4 mb_trimExternal page   8.4 mb_ucfirst & mb_lcfirst functionsExternal page   PHP 81 - array_is_list()External page  

Open in a separate window

Open in a separate window

Open in a separate window

Open in a separate window

Open in a separate window

Screenshots (6)  
  • 81__array_is_list
  • 84__mb_ucfirst.png
  • awes-test-1-640.png
  • mb_trim
  • mb_trim.jpeg
  • screenshots/85_php_build_date.png
  Files folder image Files (59)  
File Role Description
Files folder imagedocs (2 files)
Files folder imagescreenshots (7 files)
Files folder imagesrc (3 files, 1 directory)
Files folder imagetest (18 files)
Accessible without login Plain text file autoload.php Appl. Application script
Accessible without login Plain text file CHANGELOG.md Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file libin.json Data Auxiliary data
Accessible without login Plain text file LICENSE_AGL-F.md Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Reuses Unique User Downloads Download Rankings  
 0%18
Total:94
This week:0
All time:9,892
This week:46Up