note 88948 deleted from function.main by danbrown

From: Date: Wed, 17 Jun 2009 18:35:55 +0000
Subject: note 88948 deleted from function.main by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-157006@lists.php.net to get a copy of this message
Note Submitter: logan at loganmcgrath dot com ---- I've always seen "main()" used as below. You basically define all the functions required to execute your script, then throw all the other code in the Main function for when it executes. Keeps things nice and modular :D <?php // grab our necessary "header" files and settings include '../includes/bootstrap.php'; // execute our script Main(); // this is "where it all happens" function Main() { $value = value_get(); value_output_to_buffer( $value ); return; } // we define all our functions and subroutines // at the bottom of the document so we don't // have to scroll all the way down just to figure // out what our code does function value_get() { return 'This is a value!'; } function value_output_to_buffer( $value ) { echo $value; return; } ?>

« previous php.notes (#157006) next »