نسخة يونيكود: 15.0.
قم بتثبيت هذه المكتبة باستخدام الأمر Composer require :
composer require maximal/emoji ' ^1.0 ' أو أضف اسم الحزمة إلى القسم require في ملف composer.json الخاص بك:
"require": {
"maximal/emoji": "^1.0"
}
ثم قم بتشغيل:
composer updateثم قم بتضمين التحميل التلقائي للملحن في أي مكان في التعليمات البرمجية الخاصة بك:
require_once __DIR__ . ' /vendor/autoload.php ' ; use Maximal Emoji Detector ;
// Whether the given string contains emoji characters
$ isEmojiFound = Detector:: containsEmoji ( $ string );
// 'test' -> false
// 'test ?' -> true
// Whether the given string consists of emoji characters only
$ isEmojiOnly = Detector:: onlyEmoji ( $ string );
// 'test ?' -> false
// '??' -> true
// String without any emoji character
$ stringWithoutEmoji = Detector:: removeEmoji ( $ string );
// 'test ?' -> 'test '
// '??' -> ''
// All emojis of the string
$ allEmojis = Detector:: allEmojis ( $ string );
// 'test ?' -> ['?']
// '??' -> ['?', '?']
// Starting emojis of the string
$ startingEmojis = Detector:: startingEmojis ( $ string );
// '?? test' -> ['?', '?']
// 'test ?' -> []containsEmoji($string): boolيكتشف ما إذا كانت السلسلة المحددة تحتوي على حرف emoji واحد أو أكثر.
onlyEmoji($string, $ignoreWhitespace = true): boolيكتشف ما إذا كانت السلسلة المحددة تتكون من أحرف الرموز التعبيرية فقط.
تتجاهل هذه الطريقة أي مسافات وعلامات تبويب وأحرف المسافات البيضاء الأخرى ( s ). قم بتمرير false إلى المعلمة الثانية لعدم تجاهل أحرف المسافة البيضاء.
removeEmoji($string): stringإرجاع السلسلة المعطاة مع إزالة جميع أحرف الرموز التعبيرية.
allEmojis($string): arrayإرجاع مجموعة من جميع الرموز التعبيرية لسلسلة الإدخال.
startingEmojis($string, $ignoreWhitespace = true): arrayيقوم بإرجاع مجموعة من الرموز التعبيرية الأولية لسلسلة الإدخال.
تتجاهل هذه الطريقة أي مسافات وعلامات تبويب وأحرف المسافات البيضاء الأخرى ( s ). قم بتمرير false إلى المعلمة الثانية لعدم تجاهل أحرف المسافة البيضاء.
قم بإجراء اختبارات بسيطة:
php test/tests.phpالناتج المتوقع:
Tests total: 119
run: 119
succeeded: 119
failed: 0