PHP code example of richweber / yii2-gender-api
1. Go to this page and download the library: Download richweber/yii2-gender-api library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
richweber / yii2-gender-api example snippets
/** @var \richweber\gender\components\Gender $component */
$component = Yii::$app->gender;
$result = $component->checkName('Roman');
if (!isset($result->errno) && $result->accuracy > 60) {
$gender = (string) $result->gender;
var_dump($gender);
}
$result = $component->checkName(['Roman', 'Богдан']);
if (!isset($result->errno)) {
var_dump($result->result);
}
$result = $component->byLocalization('UA')->checkName('Roman');
if (!isset($result->errno) && $result->accuracy > 60) {
$gender = (string) $result->gender;
var_dump($gender);
}
$result = $component->byIP('54.201.16.177')->checkName('Roman');
if (!isset($result->errno) && $result->accuracy > 60) {
$gender = (string) $result->gender;
var_dump($gender);
}
$result = $component->byLanguage('de-DE')->checkName('Roman');
if (!isset($result->errno) && $result->accuracy > 60) {
$gender = (string) $result->gender;
var_dump($gender);
}
$result = $component->checkNameByEmail('[email protected] ');
if (!isset($result->errno) && $result->accuracy > 60) {
$gender = (string) $result->gender;
var_dump($gender);
}