hota1024 / php-string
PHP String wrapper class and methods
Installs: 6
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/hota1024/php-string
Requires (Dev)
- phpunit/phpunit: 7.1.*
This package is not auto-updated.
Last update: 2025-12-10 09:29:14 UTC
README
PHP String wrapper class and methods.
Installation
Use composer
Type this command.
composer require hota1024/php-string
Can't you use composer?
OK.
- Download this repository.
- Extract the PHPString-master.zip.
- You can use
PHPString-master/src/hota1024/String.php
How to use it?
composer
require_once "path/to/vendor/autoload.php"; $str = new hota1024\Str('Hello world!'); echo $str; # Hello world!
Don't use composer
include "path/to/String.php"; $str = new hota1024\Str('Hello world!'); echo $str; # Hello world!
Tutorial
Step1「Create String object」
$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');
Step2「Output 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!
Step3「String to Array」
$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] => ! )
Step4「Reverse string」
You can make reverse string.
$apple = new Str('Apple'); $apple->reverse(); echo $apple; # elppA
You wish reversed value?
$apple = new Str('Apple'); $rev = $apple->reversed(); echo $rev; # elppA
Step4.1「Write compact code」
$apple = new Str('Apple'); $apple->reverse(); echo $apple; # elppA
↓
$apple = new Str('Apple'); $apple->reverse()->output(); # elppA