You should, as @rgroli explains. If you don't want to worry about parentheses, you can also call header() IN exit() :
if(sth) exit(header("Location: http://example.com"));
The header header in HTTP / 1.1 always requires an absolute path; see note here .
Note: This is not a hack, because the exit code is used only if this parameter is an integer and header() is void (it exits with code = 0, normal exit). Look at it as the exit_header() function, as it should after the Location header.
Jan TuroΕ Aug 24 '10 at 10:12 2010-08-24 10:12
source share