is_writable() फ़ंक्शन
is_writable() फ़ंक्शन जांचता है कि क्या एक फ़ाइल लिखने योग्य है। यदि फ़ाइल मौजूद है और लिखने योग्य है तो true लौटाता है।
सिंटैक्स
is_writable($file_path)
उदाहरण 1
<?php
$file = "one.txt";
if (is_writable($file)) {
echo "फ़ाइल लिखने योग्य है!";
} else {
echo "फ़ाइल लिखने योग्य नहीं है!";
}
?>
आउटपुट
फ़ाइल लिखने योग्य नहीं है!
उदाहरण 2: अनुमतियों के साथ
<?php
$file_permissions = fileperms("two.txt");
$res = sprintf("%o", $file_permissions);
$file = "two.txt";
if (is_writable($file)) {
echo "फ़ाइल लिखने योग्य है!";
echo "अनुमति = $res";
} else {
echo "फ़ाइल लिखने योग्य नहीं है!";
echo "अनुमति = $res";
}
?>
आउटपुट
फ़ाइल लिखने योग्य है! अनुमति: 0777
नोट
is_writeable()इसका उपनाम है।fileperms()ऑक्टल अनुमतियाँ प्राप्त करने के लिए उपयोगी है।- फ़ाइल मौजूद होनी चाहिए।