iconv
string iconv ( string $in_charset , string $out_charset , string $str )
将字符串 str 从 in_charset 转换编码到 out_charset。
basename
string basename ( string $path [, string $suffix ] )
给出一个包含有指向一个文件的全路径的字符串,本函数返回基本的文件名。
例
<?php
$path = "/testweb/home.php";
//显示带有文件扩展名的文件名
echo basename($path);
//显示不带有文件扩展名的文件名
echo basename($path,".php");
?>
输出
home.php
home
strpos & strrpos
int strpos ( string $haystack , string $needle [, int $offset = 0 ] )
int strrpos ( string $haystack , string $needle [, int $offset = 0 ] )
needle在haystack中第一次出现的位置
needle在haystack中最后一次出现的位置
strstr & strrchr
<?php
$email = 'name@example.com';
$domain = strstr($email, '@');
echo $domain; // prints @example.com
$user = strstr($email, '@', true); // As of PHP 5.3.0
echo $user; // prints name
?>
第一次出现
<?php
// get last directory in $PATH
$dir = substr(strrchr($PATH, ":"), 1);
// get everything after last newline
$text = "Line 1\nLine 2\nLine 3";
$last = substr(strrchr($text, 10), 1 );
?>
最后一次出现
date()
$today = date("Y-m-d H:i:s"); // 2001-03-10 17:16:18 (the MySQL DATETIME format)
网友评论