电脑安全

您当前的位置:主页 > 电脑安全 >

php的字符串格式化-网络编程

来源:[db:来源]标题:   字符串    编辑:电脑技术全能网 时间:2019-09-18 16:51

原标题:php的字符串格式化-网络编程
   1.字符串的收拾:chop(),itrim(),trim()trim()函数用来收拾用户输出数据,以下表现:$name=trim($name);$email=trim($email);tirm()函数能够去除字符串开端地位和停止地位的空格,并将成果字符串前往。默许情形上来除换行符(n)回车符(r)程度(t)和垂直制表符(x0B) 字符串停止标记()和空格。以下是来自于手册Without the second parameter, rtrim() will strip these characters: * " " (ASCII 32 (0x20)), an ordinary space. * "t" (ASCII 9 (0x09)), a tab. * "n" (ASCII 10 (0x0A)), a new line (line feed). * "r" (ASCII 13 (0x0D)), a carriage return. * "" (ASCII 0 (0x00)), the NUL-byte. * "x0B" (ASCII 11 (0x0B)), a vertical tabExample#1 Usage example of rtrim()<?php$text = "ttThese are a few words :) ... ";$binary = "x09Example stringx0A";$hello = "Hello World";var_dump($text, $binary, $hello);print "n";$trimmed = rtrim($text);var_dump($trimmed);$trimmed = rtrim($text, " t.");var_dump($trimmed);$trimmed = rtrim($hello, "Hdle");var_dump($trimmed);// trim the ASCII control characters at the end of $binary// (from 0 to 31 inclusive)$clean = rtrim($binary, "x00..x1F");var_dump($clean);?>上例将输入:string(32) " These are a few words :) ... "string(16) " Example string"string(11) "Hello World"string(30) " These are a few words :) ..."string(26) " These are a few words :)"string(9) "Hello Wor"string(15) " Example string"函数explode() implode() join()explode — 应用一个字符串宰割另一个字符串字符串的排序 strcmp() strcasecmp() strnatcmp()在字符串中查找字符串 strstr() strchr() strrchr() stristr()太多了,缓缓看手册<

上一篇:PHP点点滴滴-网络编程

下一篇:没有了