een file inlezen en alle tekst verwijderen?
hey,
ik ben iets aan het maken waarmee je een .htpasswd in kan lezen en dan naam en wachtwoord kan veranderen.
maar om een nieuw naam en wachtwoord te maken wil ik ook bijv rechts van de : alles kunnen verwijderen weet iemand hoe ik dat doe??
ik ben iets aan het maken waarmee je een .htpasswd in kan lezen en dan naam en wachtwoord kan veranderen.
maar om een nieuw naam en wachtwoord te maken wil ik ook bijv rechts van de : alles kunnen verwijderen weet iemand hoe ik dat doe??
kan iemand me WEL uitleggen hoe ik dat doe?
heb die fget/fopen/fclose etc allemaal al bezocht voordat ik deze topic poste
heb die fget/fopen/fclose etc allemaal al bezocht voordat ik deze topic poste
Code (php)
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
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
<?php
$filename = 'test.txt';
$somecontent = "Add this to the file\n";
// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {
// In our example we're opening $filename in append mode.
// The file pointer is at the bottom of the file hence
// that's where $somecontent will go when we fwrite() it.
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open file ($filename)";
exit;
}
// Write $somecontent to our opened file.
if (fwrite($handle, $somecontent) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
echo "Success, wrote ($somecontent) to file ($filename)";
fclose($handle);
} else {
echo "The file $filename is not writable";
}
?>
$filename = 'test.txt';
$somecontent = "Add this to the file\n";
// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {
// In our example we're opening $filename in append mode.
// The file pointer is at the bottom of the file hence
// that's where $somecontent will go when we fwrite() it.
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open file ($filename)";
exit;
}
// Write $somecontent to our opened file.
if (fwrite($handle, $somecontent) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
echo "Success, wrote ($somecontent) to file ($filename)";
fclose($handle);
} else {
echo "The file $filename is not writable";
}
?>




