mirror of
https://github.com/php/php-src.git
synced 2025-01-08 20:17:28 +08:00
40 lines
930 B
PHP
40 lines
930 B
PHP
--TEST--
|
|
similar_text(), basic tests
|
|
--CREDITS--
|
|
Mats Lindh <mats at lindh.no>
|
|
#Testfest php.no
|
|
--INI--
|
|
precision=14
|
|
--FILE--
|
|
<?php
|
|
/* Prototype : proto int similar_text(string str1, string str2 [, float percent])
|
|
* Description: Calculates the similarity between two strings
|
|
* Source code: ext/standard/string.c
|
|
*/
|
|
var_dump(similar_text("abcdefgh", "efg"));
|
|
var_dump(similar_text("abcdefgh", "mno"));
|
|
var_dump(similar_text("abcdefghcc", "c"));
|
|
var_dump(similar_text("abcdefghabcdef", "zzzzabcdefggg"));
|
|
|
|
$percent = 0;
|
|
similar_text("abcdefgh", "efg", $percent);
|
|
var_dump($percent);
|
|
similar_text("abcdefgh", "mno", $percent);
|
|
var_dump($percent);
|
|
similar_text("abcdefghcc", "c", $percent);
|
|
var_dump($percent);
|
|
similar_text("abcdefghabcdef", "zzzzabcdefggg", $percent);
|
|
var_dump($percent);
|
|
?>
|
|
===DONE===
|
|
--EXPECTF--
|
|
int(3)
|
|
int(0)
|
|
int(1)
|
|
int(7)
|
|
float(54.545454545455)
|
|
float(0)
|
|
float(18.181818181818)
|
|
float(51.851851851852)
|
|
===DONE===
|