hiroto-k/string-builder

此包已被放弃且不再维护。未建议替代包。

PHP的字符串构建类。

1.1.0 2022-08-06 05:29 UTC

This package is auto-updated.

Last update: 2024-06-06 09:30:09 UTC


README

PHP from Packagist License

PHP的字符串构建类。

<?php

$str = 'Your String';

// Normal PHP.
// Display 'MY STRING'.
echo mb_strtoupper(str_replace('Your', 'My', $str), 'utf-8');

// Using this library.
// Display 'MY STRING'.
use HirotoK\StringBuilder\StringBuilder;

echo StringBuilder::make($str)->replace('Your', 'My')->upcase();

要求

  • PHP 7.0或更高版本
  • mbstring 扩展

安装

1. 下载此库

修改 composer.json 中的 require 指令。

{
  "require": {
    "hiroto-k/string-builder": "1.*"
  }
}

或者

$ composer require hiroto-k/php-string-builder

2. 加载 vendor/autoload.php 文件

在您的代码中加载 vendor/autoload.php

3. 使用 StringBuilder

<?php

// Load composer packages.
require "vendor/autoload.php";

// Using StringBuilder class.
use HirotoK\StringBuilder\StringBuilder;

// Create StringBuilder object.
$sb = new StringBuilder('Your string');

// Alias of '__construct'.
// This method is useful to method chain.
$sb = StringBuilder::make('Your string');

许可证

MIT许可证