PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Christian Vigh   PHP List Windows Drives   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP List Windows Drives
Retrieve the letters of the drives on Windows
Author: By
Last change:
Date: 8 years ago
Size: 1,111 bytes
 

Contents

Class file image Download
<?php
   
/****************************************************************************************************

        This example demonstrates how to use the various methods of the LogicalDrives class.

     ****************************************************************************************************/
   
require ( 'LogicalDrives.phpclass' ) ;

    if (
php_sapi_name ( ) != 'cli' )
        echo (
"<pre>" ) ;

   
$ld = new LogicalDrives ( ) ;

   
// Show assigned drive letters, with their label
    // Note that the $ld object can be accessed as an array, providing the drive letter as an index
    // (the drive letter can be followed by an optional semicolon and is not case-sensitive)
   
echo ( "Assigned drives :\n" ) ;

    foreach (
$ld -> GetAssignedDrives ( ) as $drive_letter )
        echo (
"\t$drive_letter ({$ld [ $drive_letter ] -> VolumeName})\n" ) ;

   
// Show unassigned drives
   
echo ( "Unassigned drives : " . implode ( ', ', $ld -> GetUnassignedDrives ( ) ) . "\n" ) ;

   
// Next available drive letter
   
echo ( "Next available drive : " . $ld -> GetNextAVailableDrive ( ) . "\n" ) ;