1

Has anyone ever compiled a list of all the PHP functions/methods that send output to the browser (or STDOUT when running in CLI mode)? A quick search didn't show any manual pages with this information (but I could be wrong there)

I'm interested in functions that are designed to do this, not functions that may raise warnings that would be sent directly to the browser.

The print and echo functions are the obvious ones, I'm looking for a list of lesser known output functions, like readfile.

The main reason I'm asking the question is I'd like a list of functions to check for when tracking down "early output" style errors. (headers can't be set, etc.)

1

4 Answers 4

3

Expanding list:

printf
vprintf
var_export
passthru
gzpassthru
fpassthru
debug_print_backtrace

[+] they are rather obvoius but also worth mentioning:

flush
ob_flush
ob_end_flush

And header related functions also produces output, I remember having to run php-cgi, when CLI binary was not available, and there it was especially annoying

header
setcookie
session_start /* with sessions that uses cookie */
Sign up to request clarification or add additional context in comments.

Comments

2

There is curl_exec() with setting CURLOPT_RETURNTRANSFER to false.

And are die() and exit() good enough for your list?

Edit: imagepng(), imagejpeg(), imagegif()?

And actually phpinfo().

1 Comment

And actually phpinfo() - and phpcredits().
1

Have never seen a list, but can add var_dump and print_r for starters? :)

Comments

1

There's one which is often overlooked / eschewed:

trigger_error()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.