PHP Classes

File: test/83__mb_str_pad.php

Recommend this page to a friend!
  Classes of ASCOOS CMS   PHP Backwards Compatibility Library   test/83__mb_str_pad.php   Download  
File: test/83__mb_str_pad.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Backwards Compatibility Library
Functions of newer PHP versions for older versions
Author: By
Last change:
Date: 11 months ago
Size: 4,850 bytes
 

Contents

Class file image Download
<?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) "??????"

*/
?>