PHP函数is_writeable非常奇怪的行为。
<?php
$writeok = array("uploads/", "cache/", "templates_c/", "mainfile.php");
$title = "test file php";
$content = "<table align='center'><tr><td align='left'>\n";
$error = false;
foreach ($writeok as $wok) {
echo "<br />"."../".$wok."<br />";
echo fileowner("../".$wok)."<br />";
echo filegroup("../".$wok)."<br />";
echo fileowner("../".$wok)."<br />";
echo substr(sprintf('%o', fileperms("../".$wok)), -4)."<br />";
echo filetype("../".$wok)."<br />";
if (!is_dir("../".$wok)) {
if ( file_exists("../".$wok) ) {
@chgrp("../".$wok, fileowner("../".$wok));
@chmod("../".$wok, 0666);
if (is_writeable("../".$wok)==false) {
$content .= "file ".$wok." is not writeable"."<br />";
$error = true;
}else{
$content .= "file ".$wok." is writeable"."<br />";
}
if (!is_readable("../".$wok)) {
$content .= "file ".$wok." is not readable"."<br />";
$error = true;
}else{
$content .= "file ".$wok." is readable"."<br />";
}
}
} else {
@chgrp("../".$wok, fileowner("../".$wok));
@chmod("../".$wok, 0777);
if (!is_writeable("../".$wok)) {
$content .= "dir ".$wok." is not writeable"."<br />";
$error = true;
}else{
$content .= "dir ".$wok."is writeable"."<br />";
}
if (!is_readable("../".$wok)) {
$content .= "dir ".$wok." is not readable"."<br />";
$error = true;
}else{
$content .= "dir ".$wok." is readable"."<br />";
}
}
}
$content .= "</td></tr></table>\n";
if(! $error) {
$content .= "<p>"."not error"."</p>";
}else{
$content .= "<p>"." error "."</p>";
}
echo $content;
?>
可是执行结果非常奇怪:
../uploads/
0
0
0
0777
dir
../cache/
0
0
0
0777
dir
../templates_c/
0
0
0
0777
dir
../mainfile.php
0
0
0
0666
file
dir uploads/ is not writeable
dir uploads/ is readable
dir cache/ is not writeable
dir cache/ is readable
dir templates_c/ is not writeable
dir templates_c/ is readable
file mainfile.php is not writeable
file mainfile.php is readable
error
到底是什么原因?
相关推荐
C++停车场管理系统:使用栈和单端队列分别实现了停车场与便道的模拟
停车场管理系统c语言 C++停车场管理系统:使用栈和单端队列分别实现了停车场与便道的模拟. C++停车场管理系统:使用栈和单端队列分别实现了停车场与便道的模拟.
国央企创新负责人如何进行企业创新综合能力分析?.docx
国央企创新负责人如何进行企业创新综合能力分析?
国央企在开展创新技术攻关时,如何实现技术需求与科研成果的精准匹配?.docx
国央企在开展创新技术攻关时,如何实现技术需求与科研成果的精准匹配?
国央企创新负责人如何打通科技成果与企业研发的需求对接?.docx
国央企创新负责人如何打通科技成果与企业研发的需求对接?
基于能源枢纽耦合的电热气综合能源系统稳态能流分析方法(Matlab代码实现)
内容概要:本文详细介绍了一种基于能源枢纽(Energy Hub)耦合架构的电热气综合能源系统稳态能流分析方法,并提供了完整的Matlab代码实现,属于高水平期刊论文的复现研究。该方法通过建立电、热、气多能耦合的统一数学模型,引入能源枢纽框架以整合多种能源输入输出关系,结合虚拟流建模技术和二阶锥松弛(Second-Order Cone Relaxation)优化策略,实现了对复杂综合能源系统中能量流动的高精度、高效求解,尤其适用于包含分布式电源和多能转换设备的系统稳态分析。该研究不仅具有理论深度,还具备良好的工程应用价值。; 适合人群:具备电力系统、热力系统或天然气系统等能源系统基本知识,熟悉Matlab编程环境,从事综合能源系统、智能电网、能源互联网、多能互补优化等领域研究的研究生、科研人员及工程技术人员。; 使用场景及目标:①用于教学与科研中深入理解多能耦合系统的建模原理与数值求解方法;②支撑综合能源系统的规划、运行优化、能效评估及可靠性分析等实际问题研究;③为后续开展动态能流分析、不确定性优化、多目标调度及市场机制设计等高级课题提供坚实的模型基础与代码框架。; 阅读建议:建议结合相关顶刊论文与所提供的Matlab代码同步研读,重点掌握能源枢纽的建模思想、虚拟流的物理意义、关键变量的定义方式以及约束条件的数学表达形式,并尝试在基准案例基础上调整系统参数、网络拓扑或设备配置,通过仿真实验加深对模型特性与求解性能的理解。


基础编程
