自动翻译程序员英语

发布时间:2022-07-03 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了自动翻译程序员英语脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

自动翻译程序员英语 1、桌面应用 将中文翻译成程序员英文(驼峰写法等) 2、网页应用

调用翻译接口

字母大写 ucFirst() 把字符串中的首字符转换为大写。 ucwords() 把字符串中每个单词的首字符转换为大写。 strtoupPEr() 把字符串转换为大写字母。

字母小写 lCFirst() 把字符串的首字符转换为小写。 strtolower() 把字符串转换为小写字母。

字母替换 str_replace() 替换字符串中的一些字符(对大小写敏感)。 substr_replace() 把字符串的一部分替换为另一个字符串。

PHP字符串中特殊符号 首字母去除数字 有效长度限制 去重空格 空格替换成_

_写法F1a;user_name/User_Name/USER_Name/USER_NAME 匈牙利命名法:变量名=属性+类型+对象描述 骆驼命名法:userName 帕斯卡命名法:UserName

自动翻译程序员英语

<?php
// _写法:user_name/User_Name/USER_Name/USER_NAME
// 匈牙利命名法:变量名=属性+类型+对象描述
// 骆驼命名法:userName
// 帕斯卡命名法:UserName
//匈牙利命名法写不出来啊

//  字母大写
// ucfirst() 把字符串中的首字符转换为大写。
// ucwords() 把字符串中每个单词的首字符转换为大写。
// strtoupper() 把字符串转换为大写字母。

// 字母小写
//  lcfirst() 把字符串的首字符转换为小写。
// strtolower() 把字符串转换为小写字母。

// 字母替换
// str_replace() 替换字符串中的一些字符(对大小写敏感)。
// substr_replace() 把字符串的一部分替换为另一个字符串。

// PHP字符串中特殊符号
// 首字母去除数字
// 有效长度限制
// 去重空格
// 空格替换成_
// _写法:user_name/User_Name/USER_Name/USER_NAME
// 匈牙利命名法:变量名=属性+类型+对象描述
// 骆驼命名法:userName
// 帕斯卡命名法:UserName
 
// $strs

//1=帕斯卡命名法,2=_写法,3=骆驼命名法,4、-写法
$str="hello China";
$named=new PRogrammer(1);

echo "帕斯卡命名法:".$named->programmer($str)."<br>";
$named=new programmer(2,false,false,true);
echo "_写法首字符转换为大写:".$named->programmer($str)."<br>";
$named=new programmer(2,false,true,false);
echo "_写法全部小写:".$named->programmer($str)."<br>";
$named=new programmer(2,true,false,false);
echo "_写法全部大写:".$named->programmer($str)."<br>";



$named=new programmer(4,false,false,true);
echo "-写法首字符转换为大写:".$named->programmer($str)."<br>";
$named=new programmer(4,false,true,false);
echo "-写法全部小写:".$named->programmer($str)."<br>";
$named=new programmer(4,true,false,false);
echo "-写法全部大写:".$named->programmer($str)."<br>";


$named=new programmer(3);
echo "骆驼命名法:".$named->programmer($str)."<br>";

echo "SQL 语句"."<br>".$named->create_table("ceshi", "测试表",[["field"=>$named->programmer($str),"name"=>$str]]);
 

class programmer {

    public $type = "2";
    //$this->type:1=帕斯卡命名法,2=_写法,3=骆驼命名法
    public $strtoupp = false;
    //全部大写
    public $strtolow = false;
    //全部小写  。
    public $lowe  = false;
    //首字符转换为大写
   public  function __construct($type=1,$strtoupp= false,$strtolow= false,$lowe= false)
{
    $this->type=$type;
    $this->strtoupp=$strtoupp;
    $this->strtolow=$strtolow;
    $this->lowe=$lowe;
}

//创建表
	public function create_table($tablename, $as,$data=[]) {
		$sql = "create table " . $tablename;
		$sql .= " (
		    id int not null auto_increment,typeid vArchar(40) not null  comment 'id',  ";
		    foreach ($data  as $key => $value) {
		      	$sql .= " {$value['field']} int(10) not null comment  {$value['name']} ,";
		    }
		$sql .= " creationtime int(10) not null comment  '创建时间',
		    updatetime int(10) not null comment  '更新时间' ,";
		$sql .= "Primary key ( id ))auto_increment = 1 engine=;myISAM default charset=utf8 COMMENT='" . $as . "'";

	     return $sql;	
	} 
	
  
 
    public function programmer($str) {
      
        // //   $output =$this->geturl($str);
        //   $str=json_decode('{"type":"ZH_CN2EN","errorCode":0,"elapsedTime":0,"translateResult":[[{"src":"你好中国1602790634","tgt":"Hello China 1602790634"}]]}',true);
        //   echo "<pre>";
        //   foreach ($str["translateResult"] as $key => $value) {
        //       // code...
        //   }
        //   var_dump($str["translateResult"],$output,2);die;
        //首字母大写
        //false
      
        $str = $this->strFilter($str); 
        
        // VAR_dump($this->type);die;
        //帕斯卡命名法
        if ($this->type == "1") {

            //  把字符串转换为小写字母。
            $str = strtolower($str) ;
            //把字符串中每个单词的首字符转换为大写。
            $str = ucwords($str);

            //去除首字母数字
            $str = $this->ordstr_replace($str);
            //去除空格
            $str = str_replace(' ', '', $str);
            //   var_dump($str,1);die;
            return $str;
            die;

        } else if ($this->type == "2") {
            //_写法
            //把字符串转换为大写字母。
            if ($this->strtoupp) {
                $str = strtoupper($str);
                //   var_dump("strtoupper");
            } else if ($this->strtolow) {
                //把字符串转换为小写字母。
                $str = strtolower($str);
                //   var_dump("strtolower");
            } else if ($this->lowe) {
                //  把字符串转换为小写字母。
                $str = strtolower($str) ;
                //把字符串中每个单词的首字符转换为大写。
                $str = ucwords($str);

                //   var_dump("ucwords");
            } 
 
            //去除首字母数字
            $str = $this->ordstr_replace($str);
            //去除空格
            $str = str_replace(' ', '_', $str);
            //   var_dump($str);die;
            return $str;
            die;
        } else if ($this->type == "3") {
            // var_dump(3);

            //骆驼命名法
            //  把字符串转换为小写字母。
            $str = strtolower($str) ;
            $returnstr = "";
            //去除首字母数字
            $str = $this->ordstr_replace($str);
            //  var_dump($str);
            $strarr = explode(" ",$str);
            //  var_dump($strarr,1);
            foreach ($strarr as $key => $value) {
                if ($key == 0) {
                    $returnstr.= $value;
                } else {
                    //把字符串中每个单词的首字符转换为大写
                    $returnstr.= ucfirst($value) ;
                }
                // code...
            }




            $returnstr = str_replace(' ', '', $returnstr);
            // var_dump($returnstr);
            // die;
            return $returnstr;
            die;
        }else if ($this->type == "4") {
            //_写法
            //把字符串转换为大写字母。
            if ($this->strtoupp) {
                $str = strtoupper($str);
                //   var_dump("strtoupper");
            } else if ($this->strtolow) {
                //把字符串转换为小写字母。
                $str = strtolower($str);
                //   var_dump("strtolower");
            } else if ($this->lowe) {
                //  把字符串转换为小写字母。
                $str = strtolower($str) ;
                //把字符串中每个单词的首字符转换为大写。
                $str = ucwords($str);

                //   var_dump("ucwords");
            } 
 
            //去除首字母数字
            $str = $this->ordstr_replace($str);
            //去除空格
            $str = str_replace(' ', '-', $str);
            //   var_dump($str);die;
            return $str;
            die;
        }
    }
     //去除首字母数字
    public function ordstr_replace($str) {
        if (ord($str) >= 48 and ord($str) <= 57) {
            $string = mb_convert_encoding($string, "UTF-8");
            $str = str_replace($string, '', $str);
        }
        if (ord($str) >= 48 and ord($str) <= 57) {
            $this->ordstr_replace($str);
        }
        return $str;
        die;
    }


//去除特殊字符
    public function strFilter($str) {
        $str = str_replace('`', '', $str);
        $str = str_replace('·', '', $str);
        $str = str_replace('~', '', $str);
        $str = str_replace('!', '', $str);
        $str = str_replace('', '', $str);
        $str = str_replace('@', '', $str);
        $str = str_replace('#', '', $str);
        $str = str_replace('$', '', $str);
        $str = str_replace('¥', '', $str);
        $str = str_replace('%', '', $str);
        $str = str_replace('^', '', $str);
        $str = str_replace('……', '', $str);
        $str = str_replace('&amp;', '', $str);
        $str = str_replace('*', '', $str);
        $str = str_replace('(', '', $str);
        $str = str_replace(')', '', $str);
        $str = str_replace('(', '', $str);
        $str = str_replace(')', '', $str);
        $str = str_replace('-', '', $str);
        $str = str_replace('_', '', $str);
        $str = str_replace('——', '', $str);
        $str = str_replace('+', '', $str);
        $str = str_replace('=', '', $str);
        $str = str_replace('|', '', $str);
        $str = str_replace('\', '', $str);
        $str = str_replace('[', '', $str);
        $str = str_replace(']', '', $str);
        $str = str_replace('【', '', $str);
        $str = str_replace('】', '', $str);
        $str = str_replace('{', '', $str);
        $str = str_replace('}', '', $str);
        $str = str_replace(';', '', $str);
        $str = str_replace(';', '', $str);
        $str = str_replace(':', '', $str);
        $str = str_replace(':', '', $str);
        $str = str_replace(''', '', $str);
        $str = str_replace('"', '', $str);
        $str = str_replace('“', '', $str);
        $str = str_replace('”', '', $str);
        $str = str_replace(',', '', $str);
        $str = str_replace(',', '', $str);
        $str = str_replace('<', '', $str);
        $str = str_replace('>', '', $str);
        $str = str_replace('《', '', $str);
        $str = str_replace('》', '', $str);
        $str = str_replace('.', '', $str);
        $str = str_replace('。', '', $str);
        $str = str_replace('/', '', $str);
        $str = str_replace('、', '', $str);
        $str = str_replace('?', '', $str);
        $str = str_replace('?', '', $str);
        return trim($str);
    }
}

脚本宝典总结

以上是脚本宝典为你收集整理的自动翻译程序员英语全部内容,希望文章能够帮你解决自动翻译程序员英语所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。