-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathguardClauses.php
More file actions
50 lines (30 loc) · 788 Bytes
/
guardClauses.php
File metadata and controls
50 lines (30 loc) · 788 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
function fileRead($file) {
if (file_exists($file)) {
$handle = @fopen($file, 'r');
if ($handle) {
if (fwrite($handle, 'Deneme'))
return true;
else
throw new Exception('Dosyaya yazılamadı', 3);
} else
throw new Exception('Dosya açılamadı', 2);
} else
throw new Exception('Dosya bulunamadı', 1);
}
function fileRead2($file) {
if (!file_exists($file))
throw new Exception('Dosya bulunamadı', 1);
$handle = @fopen($file, 'r');
if (!$handle)
throw new Exception('Dosya açılamadı', 2);
if (!fwrite($handle, 'Deneme'))
throw new Exception('Dosyaya yazılamadı', 3);
return true;
}
try{
//fileRead('../log.txt');
fileRead2('../log.txt');
}catch(Exception $e){
echo $e->getMessage().' Line:'.$e->getLine();
}