PHP getrusage() Function Last Updated : 28 Apr, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report The getrusage() function is an inbuilt function in PHP that returns current resource usage. Syntax: getrusage(int $mode = 0)Parameters: This function has only one parameter: $mode: This parameter will be called with RUSAGE_CHILDREN, if the mode will be 1.Return Value: This function returns an associative array that is called from the system call. All entries can be accessed by using their documented fields. If failed return false. Example 1: In the below example, will use getrusage() function and print swaps. PHP <?php $dat = getrusage(); // Number of swaps echo $dat["ru_nswap"]; ?> Output: 0 Example 2: In the below example, we will print the number of fault pages using getrusage() function. PHP <?php $dat = getrusage(); // User time used (seconds) echo $dat["ru_utime.tv_sec"]; // User time used (microseconds) echo $dat["ru_utime.tv_usec"]; ?> Output: 08624 Note: Output can be different according to the system. Reference: https://www.php.net/manual/en/function.getrusage.php Comment More infoAdvertise with us Next Article PHP | header() Function N neeraj3304 Follow Improve Article Tags : PHP PHP-function Similar Reads PHP | header() Function The header() function is an inbuilt function in PHP which is used to send a raw HTTP header. The HTTP functions are those functions which manipulate information sent to the client or browser by the Web server, before any other output has been sent. The PHP header() function send a HTTP header to a c 3 min read PHP | lstat( ) function The lstat() function in PHP is used to return information about a file or a symbolic link. It gathers statistics of the file which is sent as a parameter to the lstat() function. The function returns an array which includes information on following elements :Â Â [0] or [dev] - Device number[1] or [in 4 min read PHP | Functions A function in PHP is a self-contained block of code that performs a specific task. It can accept inputs (parameters), execute a set of statements, and optionally return a value. PHP functions allow code reusability by encapsulating a block of code to perform specific tasks.Functions can accept param 8 min read PHP | imagepng() Function The imagepng() function is an inbuilt function in PHP which is used to display image to browser or file. The main use of this function is to view an image in the browser, convert any other image type to PNG and applying filters to the image. Syntax: bool imagepng( resource $image, int $to, int $qual 2 min read PHP | parse_url() Function The parse_url() function is an inbuilt function in PHP which is used to return the components of a URL by parsing it. It parses an URL and return an associative array which contains its various components. Syntax: parse_url( $url, $component = -1 ) Parameters: This function accepts two parameters as 2 min read PHP | preg_grep() Function The preg_grep() is an inbuilt function in PHP. It returns the array consisting of the elements of the input array that match with the given pattern. Syntax : array preg_grep ( $pattern, $input [, $flags] ) Parameters Used: The preg_grep() function take three parameters that are described below: $pat 2 min read Like