PHP Classes

How to Use PHP 8 Functions in a PHP Older Version Using the Package PHP 8 Backwards Compatibility Library: Functions of PHP 8 that work in older PHP versions

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2024-12-07 (2 days ago) RSS 2.0 feedNot yet rated by the usersTotal: Not yet counted Not yet ranked
Version License PHP version Categories
phpbcl8 2.0.2Custom (specified...8.0Libraries, Language, PHP 7
Description 

Author

This package provides functions of PHP 8 that work in older PHP versions.

It provides scripts that implement functions only in newer PHP 8 versions as functions built in the PHP core engine.

Currently, it provides functions like:

- array_is_list

- mysqli_execute_query

- ini_parse_quantity

- stream_context_set_options

- json_validate

- mb_str_pad

- mb_ucfirst

- mb_lcfirst

- mb_ltrim

- mb_rtrim

- mb_trim

- http_clear_last_response_headers

- array_find

- array_find_key

- array_all

- php_build_date

Picture of ASCOOS CMS
  Performance   Level  
Name: ASCOOS CMS <contact>
Classes: 22 packages by
Country: Greece Greece
Innovation award
Innovation award
Nominee: 13x

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

<p align="center"><img src="https://apps.ascoos.com/phpbcl8/images/phpBCL_256px.png" height=256 /></p>

PHP 8 Backwards Compatibility Library

GitHub Downloads (all assets, all releases) GitHub Release GitHub Release Date GitHub repo size PHP 8 Backwards Compatibility Library - total lines PHP 8 Backwards Compatibility Library - source code lines PHP 8 Backwards Compatibility Library - files in repository

Description

This package provides functions of newer PHP 8 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.

*

SOURCEFORGE

Download phpbcl8 Download phpbcl8 Download phpbcl8 Download phpbcl8

*

Contributing

This is an open source project, open to anyone.

Contributions are welcome github

Feedback

Please send any feedback or suggestions to @ascoos (Twitter) or create an issue.

License

AGL-F

*

Download

OFFICIAL ASCOOS DOWNLOAD SITE PHP Classes PHP Classes Sourceforge phpbcl8

*

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 . '/phpbcl8/autoload.php';

<br>

*

<br>

  • [!] = FIXED
  • [+] = Added
  • [^] = Updated
  • [-] = Removed

Error FILE [compat_error.php]

This file contains support code for the remaining functions of the phpbcl8 library.

| A | PHP | phpbcl8 | TYPE | NAME | DESCRIPTION |---|-----------|--------|-----------|-------------------------|----------------------------------------- | + | ALL | 1.0.8 | FILE | compat_error.php | To support errors

phpbcl8 FILE [phpbcl.php]

This file contains support code for the remaining functions of the phpbcl8 library.

| A | PHP | phpbcl8 | TYPE | NAME | DESCRIPTION |---|-----------|--------|-----------|-------------------------|----------------------------------------- | + | ALL | 1.0.5 | FILE | phpbcl.php | To support other functions in this php library

DEPRECATED FILE [compat_deprecated.php]

The use of the contents of the deprecated-removed code file is the reverse of the use of other files versioning-based on the php version.

This means that from the PHP version that refers and to newer versions, without the use of phpbcl8 and specifically the file compat_deprecated.php, you will not be able to use this code.

| A | PHP | phpbcl8 | TYPE | NAME | DESCRIPTION |---|-----------|--------|-----------|-------------------------|----------------------------------------- | + | ALL | 1.0.0 | FILE | compat_deprecated.php | for deprecated-removed php functions | + | >= 8.1.0 | 1.0.0 | CONST | ENT_COMPAT | ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401 | + | >= 8.0.0 | 1.0.0 | CONST | MB_OVERLOAD_MAIL | = 1 | + | >= 8.0.0 | 1.0.0 | CONST | MB_OVERLOAD_STRING | = 2 | + | >= 8.0.0 | 1.0.0 | CONST | MB_OVERLOAD_REGEX | = 4 | + | >= 8.0.0 | 1.0.0 | Function | each | Return the current key and value pair from an array and advance the array cursor.

VERSIONING FILES [compat_php81x.php - compat_php85x.php]

The contents of version-based files mean that since added to a specific PHP version, without using phpbcl8, you will not be able to use them in older versions.

>"All functions in the below table were tested on Ascoos Web Extended Studio 24 with PHP 8.0 and 8.2"

| A | PHP | phpbcl8 | TYPE | NAME | DESCRIPTION |---|----------|--------|-----------|-------------------------|----------------------------------------- | + | < 8.5.0 | 2.0.0 | Constant | PHP_BUILD_DATE | that is assigned the time and date the PHP binary is built. | + | < 8.4.0 | 1.1.4 | Function | intltz_get_iana_id | Get the IANA identifier from a given timezone | + | < 8.4.0 | 1.1.2 | Function | bcdivmod | Returns an array with the quotient (whole values) as a string, and the remainder as a string containing $scale number of decimal values. | + | < 8.4.0 | 1.1.1 | Function | grapheme_str_split | Splits a string into an array of individual or chunks of graphemes. | + | < 8.4.0 | 1.1.1 | Function | array_find | Returns the VALUE of the first element from $array for which the $callback returns true. Returns NULL if no matching element is found. | + | < 8.4.0 | 1.1.1 | Function | array_find_key | Returns the KEY of the first element from $array for which the $callback returns TRUE. If no matching element is found the function returns NULL. | + | < 8.4.0 | 1.1.1 | Function | array_all | Checks whether the $callback returns TRUE for ALL the array elements. | + | < 8.4.0 | 1.1.1 | Function | array_any | Checks whether the $callback returns TRUE for ANY of the array elements. | + | < 8.4.0 | 1.1.0 | Function | http_get_last_response_headers | Get Last Response Headers | + | < 8.4.0 | 1.1.0 | Function | http_clear_last_response_headers | Clear Last Response Headers | ^ | < 8.4.0 | 1.0.7 | Function | mb_ltrim | Multi-byte safely strip white-spaces (or other characters) from the beginning of a string. | ^ | < 8.4.0 | 1.0.7 | Function | mb_rtrim | Multi-byte safely strip white-spaces (or other characters) from the end of a string. | ^ | < 8.4.0 | 1.0.7 | Function | mb_trim | Multi-byte safely strip white-spaces (or other characters) from the beginning and end of a string. | ^ | < 8.4.0 | 1.0.5 | Function | mb_ucfirst | Make a multibyte string's first character uppercase. | ^ | < 8.4.0 | 1.0.5 | Function | mb_lcfirst | Make a multibyte string's first character lowercase. | + | < 8.3.0 | 1.0.2 | Function | mb_str_pad | The str_pad() function lacks multibyte character support, causing issues when working with languages that utilize multibyte encodings like UTF-8. | + | < 8.3.0 | 1.0.9 | Function | stream_context_set_options | Sets options on the specified context. | + | < 8.3.0 | 1.0.0 | Function | json_validate | Validate an string if contains a valid json. | + | < 8.2.0 | 1.0.9 | Function | openssl_cipher_key_length | Gets the cipher key length. | + | < 8.2.0 | 1.0.8 | Function | ini_parse_quantity | Returns the interpreted size in bytes on success from an ini shorthand. | ^ | < 8.2.0 | 1.0.8 | Function | mysqli_execute_query | Prepares, binds parameters, and executes SQL statement | + | < 8.1.0 | 1.0.2 | Function | array_is_list | Checks whether a given array is a list

SIMILAR FILE [compat_similar.php]

This file implements functions that resemble the original php functions that have not been removed, but have undergone changes and cannot run on all versions.

> "All similar functions start with prefix alf_"

| A | PHP | phpbcl8 | TYPE | NAME | DESCRIPTION |---|----------|--------|-----------|-------------------------|----------------------------------------- | + | >= 8.3.0 | 1.0.9 | FILE | alf_get_class | Fixed E_DEPRECATED warning | + | ALL | 1.0.1 | FILE | compat_similar.php | for similar functions | + | ALL | 1.0.2 | Function | alf_mb_convert_case | ASCOOS LIBRARY FUNCTION : For full compatible similar mb_convert_case.


  Files folder image Files (33)  
File Role Description
Files folder imagesrc (3 files, 1 directory)
Files folder imagetest (13 files)
Accessible without login Plain text file autoload.php Aux. Configuration 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 HTML file index.html Data Empty page
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

  Files folder image Files (33)  /  src  
File Role Description
Files folder imagecompat (10 files)
  Accessible without login Plain text file coreCompatibilities.php Aux. Configuration script
  Accessible without login HTML file index.html Data Empty page
  Accessible without login Plain text file phpBCL.php Aux. Configuration script

  Files folder image Files (33)  /  src  /  compat  
File Role Description
  Accessible without login Plain text file compat_consts.php Aux. Configuration script
  Accessible without login Plain text file compat_deprecated.php Aux. Configuration script
  Accessible without login Plain text file compat_error.php Aux. Configuration script
  Accessible without login Plain text file compat_php81x.php Aux. Configuration script
  Accessible without login Plain text file compat_php82x.php Example Example script
  Accessible without login Plain text file compat_php83x.php Aux. Configuration script
  Accessible without login Plain text file compat_php84x.php Aux. Configuration script
  Accessible without login Plain text file compat_php85x.php Aux. Configuration script
  Accessible without login Plain text file compat_similar.php Aux. Configuration script
  Accessible without login HTML file index.html Data Empty page

  Files folder image Files (33)  /  test  
File Role Description
  Accessible without login Plain text file 83__mb_str_pad.php Aux. Configuration script
  Accessible without login Plain text file 84_array_all.php Aux. Configuration script
  Accessible without login Plain text file 84_array_any.php Example Example script
  Accessible without login Plain text file 84_array_find .php Aux. Configuration script
  Accessible without login Plain text file 84_array_find_key.php Aux. Configuration script
  Accessible without login Plain text file 84_bcdivmod.php Aux. Configuration script
  Accessible without login Plain text file 84_grapheme_str_split.php Aux. Configuration script
  Accessible without login Plain text file 84_intltz_get_iana_id.php Aux. Configuration script
  Accessible without login Plain text file 84__http_get_last_response_headers.php Aux. Configuration script
  Accessible without login Plain text file 84__mb_trim.php Aux. Configuration script
  Accessible without login Plain text file 84__mb_ucfirst.php Aux. Configuration script
  Accessible without login Plain text file 85_php_build_date.php Example Example script
  Accessible without login Plain text file example.php Example Example script

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 Unique User Downloads  
 100%
Total:0
This week:0