[ class tree: System ] [ index: System ] [ all elements ]

Class: System

Source Location: /PEAR-1.9.5/System.php

Class Overview

System offers cross plattform compatible system functions



  • Release: 1.9.5


  • 1997-2006 The PHP Group


Inherited Variables

Inherited Methods

Class Details

[line 59]
System offers cross plattform compatible system functions

Static functions for different operations. Should work under Unix and Windows. The names and usage has been taken from its respectively GNU commands. The functions will return (bool) false on error and will trigger the error with the PHP trigger_error() function (you can silence the error by prefixing a '@' sign after the function call, but this is not recommended practice. Instead use an error handler with

Documentation on this class you can find in:

Example usage: if (!@System::rm('-r file1 dir1')) { print "could not delete file1 or dir1"; }

In case you need to to pass file names with spaces, pass the params as an array:

System::rm(array('-r', $file1, $dir1));

[ Top ]

Method Detail

cat   [line 334]

boolean &cat( string $args)

Concatenate files

Usage: 1) $var = System::cat('sample.txt test.txt'); 2) System::cat('sample.txt test.txt > final.txt'); 3) System::cat('sample.txt test.txt >> final.txt');

Note: as the class use fopen, urls should work also (test that)

  • Return: true on success
  • Access: public


string   $args     the arguments

[ Top ]

find   [line 585]

array find( mixed $args)

The "find" command


System::find($dir); System::find("$dir -type d"); System::find("$dir -type f"); System::find("$dir -name *.php"); System::find("$dir -name *.php -name *.htm*"); System::find("$dir -maxdepth 1");

Params implmented: $dir -> Start the search at this directory -type d -> return only directories -type f -> return only files -maxdepth <n> -> max depth of recursion -name <pattern> -> search pattern (bash style). Multiple -name param allowed

  • Return: Array of found files


mixed   $args     Either array or string with the command line

[ Top ]

mkDir   [line 263]

bool mkDir( string $args)

Make directories.

The -p option will create parent directories

  • Return: True for success
  • Access: public


string   $args     the name of the director(y|ies) to create

[ Top ]

mktemp   [line 408]

mixed mktemp( [string $args = null])

Creates temporary files or directories. This function will remove the created files when the scripts finish its execution.

Usage: 1) $tempfile = System::mktemp("prefix"); 2) $tempdir = System::mktemp("-d prefix"); 3) $tempfile = System::mktemp(); 4) $tempfile = System::mktemp("-t /var/tmp prefix");

prefix -> The string that will be prepended to the temp name (defaults to "tmp"). -d -> A temporary dir will be created instead of a file. -t -> The target dir where the temporary (file|dir) will be created. If this param is missing by default the env vars TMP on Windows or TMPDIR in Unix will be used. If these vars are also missing c:\windows\temp or /tmp will be used.

  • Return: the full path of the created (file|dir) or false
  • See: System::tmpdir()
  • Access: public


string   $args     The arguments

[ Top ]

rm   [line 217]

mixed rm( string $args)

The rm command for removing files.

Supports multiple files and dirs and also recursive deletes

  • Return: PEAR_Error or true for success
  • Access: public


string   $args     the arguments for rm

[ Top ]

tmpdir   [line 480]

string tmpdir( )

Get the path of the temporal directory set in the system by looking in its environments variables.

Note: php.ini-recommended removes the "E" from the variables_order setting, making unavaible the $_ENV array, that s why we do tests with _ENV

  • Return: The temporary directory on the system

[ Top ]

which   [line 513]

mixed which( string $program, [mixed $fallback = false])

The "which" command (show the full path of a command)
  • Return: A string with the full path or false if not found
  • Author: Stig Bakken <>


string   $program     The command to search for
mixed   $fallback     Value to return if $program is not found

[ Top ]

Documentation generated on Sat, 12 Jul 2014 14:01:21 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.