php - php中的字母转换

标签 php cpu-word

有没有办法可以将我在文本框中输入的西类牙语单词更改为 php 中的英语单词。

有没有办法在 php 中做到这一点。

最佳答案

您可以使用Google AJAX Language API进行转换。 For example :

google.language.translate("Hello world", "en", "es", function(result) {
  if (!result.error) {
    var container = document.getElementById("translation");
    container.innerHTML = result.translation;
  }
});

这就是 JavaScript。有一个PHP port .

<?php
/**
* example usage
*/

// we need the page treated as utf-8, otherwise the encoding will be mangled
header('Content-Type: text/html; charset=utf-8');

// require google language api class
require_once('google.translator.php');

// translate text
$text = 'Welcome to my website.';
$trans_text = Google_Translate_API::translate($text, 'en', 'it');
if ($trans_text !== false) {
        echo $trans_text;
}
?>

关于php - php中的字母转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2793287/

相关文章:

php - 如何使用 PDO 在 PHP 中获取结果数组?

java - Java 中计算单词对的数据结构类型是什么?

ios - 仅选择整个单词 uiTextView

arrays - Lua单词搜索

python - 使用 Python 正则表达式匹配不带点的单词

byte - CRC32 STM 32 上的 CRC 外设 : byte and word streams of same data give different results

php - 获取 Shopware 6 集合元素的值,PHP

php - MySQL Date_format错误

php - 如何将登录的用户与数据库系统中所有现有用户进行比较?

php - 通过终端连接到mySql