PHP String wrapper class and methods.
Type this command.
composer require hota1024/php-string
OK.
- Download this repository.
- Extract the PHPString-master.zip.
- You can use
PHPString-master/src/hota1024/String.php
require_once "path/to/vendor/autoload.php";
$str = new hota1024\Str('Hello world!');
echo $str; # Hello world!include "path/to/String.php";
$str = new hota1024\Str('Hello world!');
echo $str; # Hello world!$string = new hota1024\Str('string value'); # Create string object.Troublesome coding hota1024\Str?
You can use this code.
use \hota1024\Str;
use \hota1024\Str;
$string = new hota1024\Str('string value');Usually use echo.
$helloworld = new Str('Hello world!');
echo $helloworld; # Hello world!If you wish objective programming code?
You can use this method.
$helloworld = new Str('Hello world!');
$helloworld->output(); # Hello world!$helloworld = new Str('Hello world!');
var_dump($helloworld->asArray()); # Array ( [0] => H [1] => e [2] => l [3] => l [4] => o [5] => [6] => w [7] => o [8] => r [9] => l [10] => d [11] => ! )You can make reverse string.
$apple = new Str('Apple');
$apple->reverse();
echo $apple; # elppAYou wish reversed value?
$apple = new Str('Apple');
$rev = $apple->reversed();
echo $rev; # elppA$apple = new Str('Apple');
$apple->reverse();
echo $apple; # elppA↓
$apple = new Str('Apple');
$apple->reverse()->output(); # elppA