$f=(string)1050089;
for($i=0;$i<strlen($f);$i++){
//echo $f{$i}.‘<br>‘; //把102输出把数字转换成字符串输出
//echo substr($f, $i,1).‘<br>‘;//把102输出把数字转换成字符串输出
Statistics Total Traffic
$f=(string)1050089;
$info="共";
for($i=0;$i<strlen($f);$i++){
$s=substr($f, $i,1);
$info.=";
}
echo $info. ‘人访问‘;
Regular expressions
Regular expression substitution
$p="/a+/"; //+表示一个以上 .表示任意字符 *0个或者多个字符
$str ="java aap mysql";
echo preg_replace($p, ‘*‘, $str);
Regular expression Verification phone number
$telp="/^1[3,5,,8][0-9]{9}$/";
$aa="1871799698";
echo preg_match($telp, $aa);
The regular expression must be 126 mailboxes,
$mailp = "/^[a-z]{1}[a-z_0-9]{3,6}@126\.com$/"
$ EM = "[email protected]"
( $mailp $em );
The regular expression Preg_match found returned 1 did not find return 0, Preg_match_all found the number of returns, did not find return 0
$ps="/\d/";
$s="he54 p12 ja544";
echo preg_match($ps, $s);//1
echo preg_match_all($ps, $s);//7
$ps="/\d/";
$s="he54 p12 ja544";
echo preg_match_all($ps, $s,$a);
echo ‘<pre>‘;
print_r($a);//打印处找到的数组
Regular expression judgment
$p="/^\w{6,8}$/";//\w表示0-9 _a-z
$s="111111111";
if(preg_match($p,$s)){
echo ‘账号合理‘;
}else{
echo ‘账号非法‘;
}
PHP build file Add content Close function
$f=fopen("f:/a.txt","a");//a为追加没有就会自动建立
fwrite($f,‘12‘);//12为填写的内容,执行一次就填入一次
//fclose($f);
\ r \ n line break 8 means append, refresh once display once
file_put_contents(‘ab.txt‘, "asdf\r\n",8);//写入数据
file_get_contents(‘a.txt‘); //读取数据
file_exists()//判断文件是否存在
echo count (file (_file_)); Statistics on the number of money bar information
echo is_dir (' F:/mysql '); Find if there is a f:/mysql if present returns 1 does not exist return 0;
From for notes (Wiz)
PHP String (iii)