Microsoft Word - Core PHP Programming Using PHP to Build Dynamic Web Sites

(singke) #1

the function will be called with the RUSAGE_CHILDREN constant. You may wish to read
the man page for more information.


<?
//show CPU time used
$rusage = getrusage(1);
print($rusage["ru_utime.tv_sec"]. " seconds
used.");
?>


boolean headers_sent()


The headers_sent function returns TRUE if HTTP headers have been sent. Headers must
precede any content, so executing a print statement or placing text outside PHP tags will
cause headers to be sent. Attempting to add headers to the stack after they're sent causes
an error.


<?
if(headers_sent())
{
print("Can't add more headers!BR>\n");
}
else
{
header("X-Debug: It's OK to send a header");
}
?>


boolean leak(integer bytes)


The leak function purposely leaks memory. It is useful mostly for testing the garbage-
collecting routines of PHP itself. You might also use it to simulate lots of memory usage
if you were stress-testing.


<?
//leak 8 megs
leak(8388608);
?>


boolean method_exists(object variable, string method)


The method_exists function returns TRUE when the named method exists in the
specified object.

Free download pdf