⊗ppPmFSFDD 349 of 447 menu

Distinguishing a Folder from a File in PHP

Suppose you have a string containing a path to a file or folder. With the help of special functions is_file and is_dir we can distinguish whether the path points to a file or to a folder.

They work as follows:

<?php $path = 'some path'; var_dump(is_file($path)); // true for a file, false for a folder var_dump(is_dir($path)); // true for a folder, false for a file ?>

Given a path. If the path leads to a folder, output a message about it.

Given a path. If the path leads to a file, output a message about it.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline