这篇文章介绍的内容是关于php的基础 ,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下
';
echo fread($fp, 10);
echo '
';
echo fseek($fp, 10);
echo '
';
echo fread($fp, 10);
echo '
';
fclose($fp);
$filename = 'demo.txt';
echo $filename . '文件大小为:'.
filesize($filename).'bytes';
filectime($filename);//文件创建时间
filemtime($filename);//文件修改时间
fileatime($filename);//文件上次访问时间
$filename = 'demo.txt';
if (file_exists($filename)) {
echo '$filename文件的上次访问时间是:'.date("Y-m-d H:i:s"
,filectime($filename));
echo '$filename文件的上创建时间是:'.date("Y-m-d H:i:s"
,filectime($filename));
echo '$filename文件的上次修改时间是:'.date("Y-m-d H:i:s"
,filemtime($filename));
}
//文件锁处理机制
$fp = fopen("demo.txt", "r+");
if (flock($fp, LOCK_EX)) {
fwrite($fp, "文件这个时候被我占用了哟\n");
flock($fp, LOCK_UN);
}else {
echo "锁失败,可能有人在操作,这个时候不能将文件上锁";
}
fclose($fp);
//目录处理函数
$dir = "d:/";
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
echo readdir($dh).'
';
echo readdir($dh).'
';
echo readdir($dh).'
';
echo readdir($dh).'
';
closedir($dh);
};
}
$dir = "d:/";
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false){
echo "文件名为:$file :
文件的类型是:".filetype($dir.$file).'
';
}
closedir($dh);
}
}
//文件权限设置
chmod("/var/wwwroot/index.html", 755);
chmod("/var/wwwroot/index.html", "u+rwx,go+rx");
chmod("/somedir/somefile", 0755);
//文件路径函数
pathinfo($path);//返回文件的各个组成部分
basename($path);//返回文件名
dirname($path);//文件目录部分
parse_url($url);//网址拆解成各部分
http_build_query($query_data);//生成url中的query字符串
http_build_url();//生成一个url
$date = [
'username'=>'php',
'area'=>'hubei'
];
echo http_build_query($date);
$path_parts = pathinfo('d:/www/index.inc.php');
echo '文件目录名:'.$path_parts['dirname']."
";
echo '文件全名:'.$path_parts['basename']."
";
echo '文件扩展名:'.$path_parts['extension']."
";
echo '不包含扩展的文件名:'.$path_parts['filename']."
";
echo "1: ".basename("d:/www/index.d",".d").PHP_EOL;
echo "2: ".basename("d:/www/index.php").PHP_EOL;
echo "3: ".basename("d:/www/passwd").PHP_EOL;
$url = 'http://username:password@hostname:9090/path?arg=value#anchor';
var_dump(parse_url($url));
//文件留言本
// date_default_timezone_set('PRC');
@$string = file_get_contents('message.txt');
if (!empty($string)) {
$string = rtrim($string, '&^');
$arr = explode('&^', $string);
foreach ($arr as $value){
list($username, $content, $time) = explode('$#', $value);
echo '用户名为'.$username.'';
echo '
';
}
}
$fp=fopen('message.txt', 'a');
$time=time();
$username=trim(@$_POST['username']);
$content=trim(@$_POST['content']);
if ($username & $content) {
$string=$username.'$#'.$content.'$#'.$time.'&^';
fwrite($fp, $string);
fclose($fp);
}
?>
基于文本的留言本演示
$val){
$yx="/define\('$key','.*?'\);/";
$re="define('$key','$val');";
$string=preg_replace($yx, $re, $string);
}
file_put_contents('config.php', $string);
echo '修改成功';
?>
相关推荐:
战刀API淘客自动采集系统是一个以php+MySQL进行开放的淘宝客网站程序。程序说明:1.老Y文章系统更改为php战刀API淘宝客系统。2.本程序就是基于"淘宝客基础API"开发出来的产品 。3.现在淘宝客API 重新开放申请 商品全自动更新。网站功能:1.现在淘宝客API 重新开放申请,本程序就是基于"淘宝客基础API"开发出来的产品,海量商品全自动更新










