RE: [PHP] Subroutines
they're just functions function your_function($arg1,$arg2){ echo $arg1; echo $arg2; } -Original Message- From: Chris Herring [mailto:[EMAIL PROTECTED]] Sent: Sunday, September 30, 2001 2:08 AM To: php list Subject: Re: [PHP] Subroutines My bad, http://www.b000.net/code/ - Original Message - From: Chris Herring [EMAIL PROTECTED] To: php list [EMAIL PROTECTED] Sent: Sunday, September 30, 2001 1:07 AM Subject: [PHP] Subroutines I've looked through the manual (or at least searched) for subroutines, and I can't find them, there's a guy I know who made a script with custom PHP subroutines. (http://b000.net/) Anyway, I want to know how to make them. Thanks for any input. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Subroutines
My bad, http://www.b000.net/code/ - Original Message - From: Chris Herring [EMAIL PROTECTED] To: php list [EMAIL PROTECTED] Sent: Sunday, September 30, 2001 1:07 AM Subject: [PHP] Subroutines I've looked through the manual (or at least searched) for subroutines, and I can't find them, there's a guy I know who made a script with custom PHP subroutines. (http://b000.net/) Anyway, I want to know how to make them. Thanks for any input. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] subroutines?
On Wednesday 08 August 2001 01:37, CGI GUY wrote: How does PHP compensate for an apparent lack of traditional subroutines (as with Perl, etc.)? It seems like I'm going to have to script separate pages for ea. set of processes in my search (i.e., print FORM, print results for SEARCH, print DETAILS, etc.). Please tell me I'm mistaken! http://www.php.net/manual/en/functions.php http://www.php.net/manual/en/function.require-once.php http://www.php.net/manual/en/control-structures.switch.php http://www.php.net/manual/en/language.oop.php -- Christian Reiniger LGDC Webmaster (http://lgdc.sunsite.dk/) World domination. Fast. (Linus Torvalds about Linux) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] subroutines?
Hi again, As a new PHP convert, I ran into this same problem (below) yesterday while designing a form. ASP programmers (if they're THINKING) will use subs to keep if blocks tidy. In ASP, I'd use something like: If Request.ServerVariables( REQUEST_METHOD ) = GET Then DisplayForm Else SendFormData End If which at first I replaced with: if ( getenv( REQUEST_METHOD ) == GET ) { display_form(); } else { send_email(); } ...making functions out of what used to be subroutines. All well-and-good, except my global variables disappeared and nothing I could do (even declaring the few important ones explicitly global) seemed to allow me to get at the variable contents. I wound up compromising by sending just the bits I needed in the function INTO the function like so: $MyURI = $SCRIPT_NAME; $TheFormVars = $HTTP_POST_VARS; if ( getenv( REQUEST_METHOD ) == GET ) { display_form( $MyURI ); } else { send_email( $TheFormVars, $ThisWebServerFQDN ); } Seems a bit tacky at first, but it works (properly!) and that's all that counts. I can do much more with PHP functions just as they are than I ever could with ASP; moreover, I have much more secure control of what gets exposed where. To me, a beautiful compromise since at no point is there ever an actual email address exposed to the outside world. My Support Topic selection box contains arbitrary codes that allow me to generate the appropriate email address on the fly. Hope my experience will be helpful to other noobies making the Big Transition. Best regards, Bill -Original Message- From: Christian Reiniger [mailto:[EMAIL PROTECTED]] Sent: Thursday, August 09, 2001 8:21 AM To: CGI GUY; [EMAIL PROTECTED] Subject: Re: [PHP] subroutines? On Wednesday 08 August 2001 01:37, CGI GUY wrote: How does PHP compensate for an apparent lack of traditional subroutines (as with Perl, etc.)? It seems like I'm going to have to script separate pages for ea. set of processes in my search (i.e., print FORM, print results for SEARCH, print DETAILS, etc.). Please tell me I'm mistaken! http://www.php.net/manual/en/functions.php http://www.php.net/manual/en/function.require-once.php http://www.php.net/manual/en/control-structures.switch.php http://www.php.net/manual/en/language.oop.php -- Christian Reiniger LGDC Webmaster (http://lgdc.sunsite.dk/) World domination. Fast. (Linus Torvalds about Linux) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] subroutines?
[EMAIL PROTECTED] wrote: As a new PHP convert, I ran into this same problem (below) yesterday while designing a form. ASP programmers (if they're THINKING) will use subs to keep if blocks tidy. In ASP, I'd use something like: If Request.ServerVariables( REQUEST_METHOD ) = GET Then DisplayForm Else SendFormData End If which at first I replaced with: if ( getenv( REQUEST_METHOD ) == GET ) { display_form(); } else { send_email(); } ...making functions out of what used to be subroutines. All well-and-good, except my global variables disappeared and nothing I could do (even declaring the few important ones explicitly global) seemed to allow me to get at the variable contents. Bill, You need to declare the variables global within each function that access them or access the variable via the $GLOBALS array. $var = 'something'; function go() { return $GLOBALS[var]; } or function go() { global $var; return $var; } echo go(); -- Steve Werby President, Befriend Internet Services LLC http://www.befriend.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] subroutines?
How does PHP compensate for an apparent lack of traditional subroutines (as with Perl, etc.)? It seems like I'm going to have to script separate pages for ea. set of processes in my search (i.e., print FORM, print results for SEARCH, print DETAILS, etc.). Please tell me I'm mistaken! Use functions. Use switch(). Use a form that submits to itself. I feel like a Trainspotting poster. :) Jason -- Jason Murray [EMAIL PROTECTED] Web Developer, Melbourne IT Work now, freak later! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] subroutines?
Jason pretty well suggested what to use. PHP scripts with a lot of logic in them usually have all the function definitions and logic at the top of the script and the display stuff at the end. Again, as I'm always recommending, have a look at Julie Meloni's Thickbook tutorials, particularly the custom error messages example. http://www.thickbook.com Have fun - Miles At 04:37 PM 8/7/01 -0700, CGI GUY wrote: How does PHP compensate for an apparent lack of traditional subroutines (as with Perl, etc.)? It seems like I'm going to have to script separate pages for ea. set of processes in my search (i.e., print FORM, print results for SEARCH, print DETAILS, etc.). Please tell me I'm mistaken! __ Do You Yahoo!? Make international calls for as low as $.04/minute with Yahoo! Messenger http://phonecard.yahoo.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]