note 85071 added to function.ob-end-clean

From: Date: Wed, 13 Aug 2008 18:21:46 +0000
Subject: note 85071 added to function.ob-end-clean
Groups: php.notes 
Request: Send a blank email to php-notes+get-143452@lists.php.net to get a copy of this message
I was struggling with a way to have a single function called show_app() do triple-duty in a set of scripts: 1. Be an edit/input form (an application for admission, in this case) 2. Display the saved content of the application 3. Iteratively write the formatted HTML of selected students' applications out to separate .htm files for export to another system, but NOT display the HTML Number 3 was a challenge but I finally ended up with this, which worked beautifully. Figured I'd share in case it saves someone else some time: <?php # previously did a select on the student data to be included # now name the input file in this batch last_first_dob.htm $studname=$last_name.'_'.$first_name.'_'.$dob.'.htm'; # specify the path for the exported html # note the \\ for windows systems - *nix would end in a single \ $studfilename = "C:\Program Files\Apache2.2\htdocs\apply\exports\\".$studname; ob_start(); # call the function show_app(); # capture the output of the function $appcont = ob_get_contents(); # open the export file for writing $studfile = fopen("$studfilename", 'w'); # write the captured output to the file fwrite($studfile, $appcont); # close the export file fclose($studfile); # empty the output buffer WITHOUT displaying the content to the screen ob_end_clean(); ?> ---- Server IP: 208.69.120.35 Probable Submitter: 192.231.233.104 ---- Manual Page -- http://www.php.net/manual/en/function.ob-end-clean.php Edit -- https://master.php.net/note/edit/85071 Del: integrated -- https://master.php.net/note/delete/85071/integrated Del: useless -- https://master.php.net/note/delete/85071/useless Del: bad code -- https://master.php.net/note/delete/85071/bad+code Del: spam -- https://master.php.net/note/delete/85071/spam Del: non-english -- https://master.php.net/note/delete/85071/non-english Del: in docs -- https://master.php.net/note/delete/85071/in+docs Del: other reasons-- https://master.php.net/note/delete/85071 Reject -- https://master.php.net/note/reject/85071 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#143452) next »