小编shy*_*ick的帖子

Php创建一个文件,如果不存在

我尝试创建文件并动态编写内容.以下是我的代码.

$sites = realpath(dirname(__FILE__)).'/';
$newfile = $sites.$filnme_epub.".js";

if (file_exists($newfile)) {
    $fh = fopen($newfile, 'a');
    fwrite($fh, 'd');
} else {
    echo "sfaf";
    $fh = fopen($newfile, 'wb');
    fwrite($fh, 'd');
}

fclose($fh);
chmod($newfile, 0777);

// echo (is_writable($filnme_epub.".js")) ? 'writable' : 'not writable';
echo (is_readable($filnme_epub.".js")) ? 'readable' : 'not readable';
die;
Run Code Online (Sandbox Code Playgroud)

但是,它不会创建文件.

请分享您的答案和帮助.谢谢!

php file-handling

14
推荐指数
3
解决办法
7万
查看次数

eval和逻辑表达式检查

我必须评估动态表达式,并根据条件,我需要显示另一个div.

我的表达是:

{ [appln.module.name.VALUE] == 1 && [appln.module.name.VALUE] != EFT }
Run Code Online (Sandbox Code Playgroud)

如果这两个表达式都满足条件,则必须显示div.该值将根据所做的更改计算.

有人可以帮助解决这个问题,如何动态地解析和评估条件?

php regex logical-operators

5
推荐指数
1
解决办法
278
查看次数

标签 统计

php ×2

file-handling ×1

logical-operators ×1

regex ×1