note 85071 deleted from function.ob-end-clean by nicos

From: Date: Thu, 14 Aug 2008 00:47:49 +0000
Subject: note 85071 deleted from function.ob-end-clean by nicos
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-143471@lists.php.net to get a copy of this message
Note Submitter: goellerk at bucks dot edu Reason: 2 ---- 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(); ?>

« previous php.notes (#143471) next »