PHP Classes

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

Recommend this page to a friend!
  Info   View files Example   View files View files (22)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog (2)    
Last Updated Ratings Unique User Downloads Download Rankings
2023-07-13 (4 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 74 All time: 10,125 This week: 128Up
Version License PHP version Categories
phpbcl 1.0.3Freeware5PHP 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.

Currently, it provides the following functions:

- Deprecated: each

- Implemented in PHP 7.4: password_algos

- Implemented in PHP 8.0: str_contains, str_ends_with, str_starts_with, Stringable

- Implemented in PHP 8.1: array_is_list

- Implemented in PHP 8.3: json_validate

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  
Name: ASCOOS CMS <contact>
Classes: 6 packages by
Country: Greece Greece
Age: ???
All time rank: 422325 in Greece Greece
Week rank: 609 Up6 in Greece Greece Up
Innovation award
Innovation award
Nominee: 3x

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 - 2023, AlexSoft Software. *
 *************************************************************************************
 *
 * @package : ASCOOS CMS - phpBCL
 * @subpackage : Example mb_str_pad Function
 * @source : /phpBCL/test/mb_str_pad.php
 * @version : **** - $release: 1.0 - $revision: 1 - $build: ****
 * @created : 2023-07-07 07:00:00 UTC+3
 * @updated :
 * @author : Drogidis Christos
 * @authorSite : www.alexsoft.gr
 */

define('ALEXSOFT_RUN_CMS', true);

$cms_path = str_replace('/phpBCL/test', '',str_replace('\\', '/', __DIR__));
 
require_once(
$cms_path."/phpBCL/src/coreCompatibilities.php");


 
// This will pad such that the string will become 10 bytes long.
var_dump(str_pad('Franšais', 10, '_', STR_PAD_RIGHT)); // BAD: string(10) "Franšais_"
var_dump(str_pad('Franšais', 10, '_', STR_PAD_LEFT)); // BAD: string(10) "_Franšais"
var_dump(str_pad('Franšais', 10, '_', STR_PAD_BOTH)); // BAD: string(10) "Franšais_"

// This will pad such that the string will become 10 characters long, and in this case 11 bytes.
var_dump(mb_str_pad('Franšais', 10, '_', STR_PAD_RIGHT));// GOOD: string(11) "Franšais__"
var_dump(mb_str_pad('Franšais', 10, '_', STR_PAD_LEFT)); // GOOD: string(11) "__Franšais"
var_dump(mb_str_pad('Franšais', 10, '_', STR_PAD_BOTH)); // GOOD: string(11) "_Franšais_"



var_dump(str_pad('??? ????? ????????.', 21, '_', STR_PAD_RIGHT)); // BAD: string(35) "??? ????? ????????."
var_dump(str_pad('??? ????? ????????.', 21, '_', STR_PAD_LEFT)); // BAD: string(35) "??? ????? ????????."
var_dump(str_pad('??? ????? ????????.', 21, '_', STR_PAD_BOTH)); // BAD: string(35) "??? ????? ????????."

var_dump(mb_str_pad('??? ????? ????????.', 4, '_', STR_PAD_RIGHT)); // ERROR: string(0) "" Return TriggerError
var_dump(mb_str_pad('??? ????? ????????.', 21, '_', STR_PAD_RIGHT)); // GOOD: string(37) "??? ????? ????????.__"
var_dump(mb_str_pad('??? ????? ????????.', 21, '_', STR_PAD_LEFT)); // GOOD: string(37) "__??? ????? ????????."
var_dump(mb_str_pad('??? ????? ????????.', 21, '_', STR_PAD_BOTH)); // GOOD: string(37) "_??? ????? ????????._"


var_dump(str_pad('??', 6, '???', STR_PAD_RIGHT)); // BAD: string(6) "??"
var_dump(str_pad('??', 6, '???', STR_PAD_LEFT)); // BAD: string(6) "??"
var_dump(str_pad('??', 6, '???', STR_PAD_BOTH)); // BAD: string(6) "??"

var_dump(mb_str_pad('??', 6, '???', STR_PAD_RIGHT)); // GOOD: string(18) "??????"
var_dump(mb_str_pad('??', 6, '???', STR_PAD_LEFT)); // GOOD: string(18) "??????"
var_dump(mb_str_pad('??', 6, '???', STR_PAD_BOTH)); // GOOD: string(18) "??????"

/*
string(10) "Franšais_"
string(10) "_Franšais"
string(10) "Franšais_"
string(11) "Franšais__"
string(11) "__Franšais"
string(11) "_Franšais_"
string(35) "??? ????? ????????."
string(35) "??? ????? ????????."
string(35) "??? ????? ????????."
<br />
<b>Warning</b>: mb_str_pad(): The length of string is greater than the length specified in parameter 2. Increase the size of parameter 2 to >= 20 in <b>....\phpBCL\src\compat\compat_php83x.php</b> on line <b>151</b><br />
string(0) ""
string(37) "??? ????? ????????.__"
string(37) "__??? ????? ????????."
string(37) "_??? ????? ????????._"
string(6) "??"
string(6) "??"
string(6) "??"
string(18) "??????"
string(18) "??????"
string(18) "??????"

*/
?>


Details

<p align="center"><img src="https://dl.ascoos.com/images/ascoos.png" height=120 /></p>

PHP Backwards Compatibility Library (phpBCL)

Description

These is PHP Backwards Compatibility Library (phpBCL).

*

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 on GitHub.

License

AGL-F (ASCOOS General License - Free)

*

<br>

Download

  1. GITHUB
  2. www.phpclasses.org

<br>

*

<br>

Installation and use this library

  1. Download latest release
  2. Unzip package in your working directory
  3. Add in index.php or configuration file the variable `$cms_path = "FULL PATH"`. It should contain the full path where the index.php file is located.
  4. Add `require_once($cms_path."/phpBCL/src/coreCompatibilities.php");` in index.php
  5. Run your code

<br>

*

<br>

Changelog

1.0.3 [2023-07-12]

PHP < 8.2.0

  • Added Functions `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 Functions: `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`
  • Added Similar Functions: ASCOOS LIBRARY FUNCTION `alf_mb_convert_case` For full compatible similar mb_convert_case.

PHP < 7.4.0

  • Added Functions: `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 Functions: `array_is_list`

PHP < 8.3.0

  • Added Functions: `mb_str_pad`

*

1.0.1 [2023-06-27]

  • Added file compat_similar.php (for similar functions)

PHP < 7.1.0

  • Added Functions: `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

  Files folder image Files  
File Role Description
Files folder imagesrc (1 file, 1 directory)
Files folder imagetest (7 files)
Accessible without login Plain text file CHANGELOG.md Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  src  
File Role Description
Files folder imagecompat (12 files)
  Accessible without login Plain text file coreCompatibilities.php Aux. Auxiliary script

  Files folder image Files  /  src  /  compat  
File Role Description
  Accessible without login Plain text file compat_deprecated.php Aux. Auxiliary script
  Plain text file compat_php43x.php Class Class source
  Plain text file compat_php55x.php Class Class source
  Accessible without login Plain text file compat_php71x.php Aux. Auxiliary script
  Accessible without login Plain text file compat_php73x.php Aux. Auxiliary script
  Accessible without login Plain text file compat_php74x.php Aux. Auxiliary script
  Plain text file compat_php80x.php Class Class source
  Accessible without login Plain text file compat_php81x.php Aux. Auxiliary script
  Plain text file compat_php82x.php Class Added in 1.0.3
  Accessible without login Plain text file compat_php83x.php Example Example script
  Accessible without login Plain text file compat_similar.php Aux. Auxiliary script
  Accessible without login HTML file index.html Doc. Documentation

  Files folder image Files  /  test  
File Role Description
  Accessible without login Plain text file 55__array_column.php Example Example script
  Accessible without login Plain text file 73__mb_convert_case.php Example Example script
  Accessible without login Plain text file 74_mb_str_split.php Example Example script
  Accessible without login Plain text file 80__class_Stringable.php Example Example script
  Accessible without login Plain text file 81__array_is_list.php Example Example script
  Accessible without login Plain text file 83__mb_str_pad.php Example Example script
  Accessible without login Plain text file example.php Example Example script

 Version Control Unique User Downloads Download Rankings  
 100%
Total:74
This week:0
All time:10,125
This week:128Up