jimfog Posted December 14, 2012 Share Posted December 14, 2012 When you use var_dump to output the content of a variable into the browser is this still considered output in the sense that an echo statement is? Link to comment Share on other sites More sharing options...
birbal Posted December 14, 2012 Share Posted December 14, 2012 yes both are same. browser does not know It is generate by var_dump() or echo or print_r() if anything is sent and printed it will be considered as output Link to comment Share on other sites More sharing options...
jimfog Posted December 19, 2012 Author Share Posted December 19, 2012 (edited) Ok...I understood that. But what about the head section of a page. I am talking about the tags inside <head></head>. I am asking this cause I am facing a strange case. Normally I should get an error but I do not-take a look at this code: include 'header.html'; if(isset($_POST['submit'])&&(!empty($_POST['remember']))) { $username = $_POST['username']; $passwd = $_POST['password']; if ((login($username, $passwd))) { setcookie_pers($username); header("Location: adminmember.php"); } } If the user fills in the login form and ticks the remember me option a cookie a cookie is set(this is what the function setcookie_pers does). Everything happens though after the head section which is included above by using include. How happens and I do not get any errors? The header.html file contains the title page plus all the tags contained in <head></head> I finally got an error(the usual "output started...headers already sent"), although I do not understand why this was not happening from the beginning. Very weird...no error again. Edited December 19, 2012 by jimfog Link to comment Share on other sites More sharing options...
boen_robot Posted December 23, 2012 Share Posted December 23, 2012 From PHP's point of view, "output" is "HTTP content", i.e. anything that is sent to the client that is not an "HTTP header". Cookies are sent as headers.PHP may be configured to delay sending "output" until execution of the PHP file is finished (the so called "output buffering"). In that case, within the PHP file, it may look "as if" you're first writing output and then send headers, but in reality, PHP is still always sending headers first and content afterwards. If you use this "feature", the user won't see anything until the PHP file is finished, so your file better be fast. Link to comment Share on other sites More sharing options...
jimfog Posted December 24, 2012 Author Share Posted December 24, 2012 One small question...So, as I understand, the head section of a page(<head>...and whatever tags are contained in it) are not considered HTTP headers Am I right? Link to comment Share on other sites More sharing options...
thescientist Posted December 25, 2012 Share Posted December 25, 2012 no, they would be considered HTTP headers. when dealing without output from PHP script, any kind of output, whitespace, BOM, etc is considered output to the browser. It has no idea of what generated the output, other than output was generated. Link to comment Share on other sites More sharing options...
jimfog Posted December 25, 2012 Author Share Posted December 25, 2012 The phrase below is taken from the PHP manual-on the section about the setcookie() function: This requires that you place calls to this function prior to any output, including <html> and <head> tags as well as any whitespace. According to the above the head section is considered output-at least that is what I understand-correct me if I am wrong. Link to comment Share on other sites More sharing options...
Ingolme Posted December 26, 2012 Share Posted December 26, 2012 Anything that you can see in the source code sent to the browser is output. All HTML and text, and anything that isn't PHP logic. Link to comment Share on other sites More sharing options...
jimfog Posted December 26, 2012 Author Share Posted December 26, 2012 Anything that you can see in the source code sent to the browser is output. All HTML and text, and anything that isn't PHP logic.So I am right to say that <head> is considered output. Link to comment Share on other sites More sharing options...
boen_robot Posted December 26, 2012 Share Posted December 26, 2012 So I am right to say that <head> is considered output.Yes. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now