note 88948 added to function.main
| From: | logan at loganmcgrath dot com | Date: | Sat, 14 Feb 2009 18:21:31 +0000 |
| Subject: | note 88948 added to function.main | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-150681@lists.php.net to get a copy of this message | ||
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;
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 71.244.50.194
----
Manual Page -- http://www.php.net/manual/en/function.main.php
Edit -- https://master.php.net/note/edit/88948
Del: integrated -- https://master.php.net/note/delete/88948/integrated
Del: useless -- https://master.php.net/note/delete/88948/useless
Del: bad code -- https://master.php.net/note/delete/88948/bad+code
Del: spam -- https://master.php.net/note/delete/88948/spam
Del: non-english -- https://master.php.net/note/delete/88948/non-english
Del: in docs -- https://master.php.net/note/delete/88948/in+docs
Del: other reasons-- https://master.php.net/note/delete/88948
Reject -- https://master.php.net/note/reject/88948
Search -- https://master.php.net/manage/user-notes.php