Download the PHP package fw3_for_old/strings without Composer
On this page you can find all versions of the php package fw3_for_old/strings. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download fw3_for_old/strings
More information about fw3_for_old/strings
Files in fw3_for_old/strings
Package strings
Short Description Flywheel3 framework: string processing library for old php versions
License MIT
Homepage https://ickx.jp
Informations about the package strings
Flywheel3 String processing library for old php versions
Rapid Development FrameworkであるFlywheel3 の文字列処理ライブラリです。
fw3/strings: Flywheel3 strings processing libraryで公開しているStringBuilderをPHP5.3.3以降でも動作するようにした、実用向けのストリームフィルタです。
お手軽簡単、今すぐに利用したい方は 使い方 を参照してください。
PHP7.2.0未満への対応が不要な場合、 fw3/strings を使用してください。
対象バージョンおよび動作確認バージョン
対象バージョン:PHP5.3.3以降
動作確認バージョン
- 5.3.3
- 5.3.4
- 5.3.5
- 5.3.6
- 5.3.7
- 5.3.8
- 5.3.9
- 5.4.16
- 5.4.39
- 5.4.45
- 5.5.38
- 5.6.40
- 7.0.33
- 7.1.33
- 7.2.33
- 7.3.21
- 7.4.0
- 7.4.9
- 8.0.0beta2
設定などの注意点
Windows (php7.2.0未満)
php.iniの次の行のコメントを除去してください。
Windows (php7.2.0以上)
php.iniの次の行のコメントを除去してください。
Linux系 (パッケージマネージャ使用)
各種パッケージマネージャでphp-mbstring
またはそれに類するものをインストールしてください。
Linux系 (phpenv使用)
default_configure_options
または各definitionに次の一つを追加してください。
Linux系 (ソースコードからビルド)
configureオプションに次の一つを追加してください。 詳細はPHP マニュアル 関数リファレンス 自然言語および文字エンコーディング マルチバイト文字列 インストール/設定を参照してください。
使い方
1 . インストール
composerを使用できる環境の場合
次のコマンドを実行し、インストールしてください。
composer require fw3_for_old/strings
composerを使用できない環境の場合
Download ZIPよりzipファイルをダウンロードし、任意のディレクトリにコピーしてください。
使用対象となる処理より前にrequire_once sprintf('%s/src/strings_require_once.php', $path_to_copy_dir);
としてsrc/strings_require_once.php
を読み込むようにしてください。
主な機能
StringBuilder - 文字列テンプレートエンジン
PDOにおける名前付きプレースホルダのようなテンプレート文字列を扱えます。
SmartやTwigのように変数に対して修飾したり、実行時に変数名から動的に値を返したり、複数の変数から、見つかり次第値を埋めるといったことが可能です。
Converter - 文字列変換器
エスケープや安全なJSONize、ケースコンバート、変数の文字列表現化を行えます。
機能詳細:StringBuilder
次の例の用にあらかじめフォーマットが定まった文字列に対して、容易に値を展開することができます。
いずれかの値が変数として存在する場合に、見つかり次第展開することもできます。
SmartやTwigのように変数に対して修飾を行う事も出来ます。
デバッグやエラーログの取り扱いに便利な文字列の出力も行えます。
機能詳細:Converter
escape
HTML用のエスケープとJavaScript用のエスケープを提供します。
実行時に動的にエスケープタイプを変更したい場合はescape
を使用します。
明確にescapeする対象が定まっている場合はhtmlEscapeなどの特化処理を利用してください。
HTMLに特化したescape処理はhtmlEscape
を使用してください。
同様にJavaScriptに特化したescape処理はjsEscape
を使用してください。
JSONize
与えられたPHP変数を安全なJSON文字列に変換します。
ケースコンバート
SNAKE_CASEやCHAIN-CASE、CamelCaseを相互に変換します。
to SNAKE_CASE
to CHAIN_CASE
to CamelCase
変数情報展開
変数に関する情報を文字列にします。
変数が実際はどういう状態になっているかをさっと見たりログに残したりする場合に便利です。
配列などの階層構造になっている値は指定した深さまでは表示するように制約できます。
実際に感謝されたケースはfalseやnullなどの文字列化した場合に空文字となってしまった場合や、数値が文字列か整数かを簡単に識別できた場合などでした。