Oihana PHP Commands

silent.php

Table of Contents

Functions

silent()  : string|null
Appends a redirection string to suppress output from a shell command.

Functions

silent()

Appends a redirection string to suppress output from a shell command.

silent(string|null &$command[, bool $silent = false ]) : string|null

This helper function modifies the given command string in-place by appending a platform-appropriate silence directive:

  • On Unix/Linux/macOS: > /dev/null 2>&1
  • On Windows: > NUL 2>&1

This is typically used to hide output when executing shell commands.

Parameters
$command : string|null

The command string to modify by reference.

$silent : bool = false

Whether to append the silence directive to the command.

Tags
example
$cmd = 'wp plugin install hello-dolly';
silent($cmd, true);
echo $cmd;
// Output (Unix)    : wp plugin install hello-dolly > /dev/null 2>&1
// Output (Windows) : wp plugin install hello-dolly > NUL 2>&1
author

Marc Alcaraz (ekameleon)

since
1.0.0
Return values
string|null

The updated command string (or null if input was null).


        
On this page

Search results