public static function getScreenWidth() {

        // set a simple error handler that indicates the exec function was disabled
        set_error_handler("self::errorHandler", E_WARNING);

        // initialize the array for the output of the execute
        $output = [];

        // execute the bash command tput cols to determine the screen width
        $width = exec("tput cols 2>&1", $output);

        // if the height is zero, then something went wrong
        if (count($output) == 0 ||$width == 0 || $width == "" || is_null($width)) {

            // use the error handler to raise the exception
            self::errorHandler(null,null);


        }

        // put back the error handler
        restore_error_handler();

        // return the height
        return intval($width);


    }
public static function getScreenWidth() {

        // set a simple error handler that indicates the exec function was disabled
        set_error_handler("self::errorHandler", E_WARNING);

        // initialize the array for the output of the execute
        $output = [];

        // execute the bash command tput cols to determine the screen width
        $width = exec("tput cols 2>&1", $output);

        // if the height is zero, then something went wrong
        if (count($output) == 0 ||$width == 0 || $width == "" || is_null($width)) {

            // use the error handler to raise the exception
            self::errorHandler(null,null);


        }

        // put back the error handler
        restore_error_handler();

        // return the height
        return intval($width);


    }
public static function getScreenWidth ( ) { // set a simple error handler that indicates the exec function was disabled set_error_handler ( "self::errorHandler" , E_WARNING ) ; // initialize the array for the output of the execute $ output = [ ] ; // execute the bash command tput cols to determine the screen width $ width = exec ( "tput cols 2>&1" , $ output ) ; // if the height is zero, then something went wrong if ( count ( $ output ) == 0 || $ width == 0 || $ width == "" || is_null ( $ width ) ) { // use the error handler to raise the exception self :: errorHandler ( null , null ) ; } // put back the error handler restore_error_handler ( ) ; // return the height return intval ( $ width ) ; }
Get the current screen width

@uses errorHandler
@return int - the number of characters that will fit across the screen
@throws RuntimeException
Get the current screen width