[PHP] passing GET via include
Hello all, Is there a way to allow the passing of variables to included scripts using the GET method, for example includefile.php?name=person; or is there another method of including files that allow you to do this. I have attempted to do this without success, I just get a message saying the file cannot be found. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] passing GET via include
Mark Smith escribió: Hello all, Is there a way to allow the passing of variables to included scripts using the GET method, for example includefile.php?name=person; or is there another method of including files that allow you to do this. I have attempted to do this without success, I just get a message saying the file cannot be found. If you define the variables before the *include* the included file will see them without problem... -- Miguel J. Jiménez Programador Senior Área de Internet/XSL/PHP [EMAIL PROTECTED] ISOTROL Edificio BLUENET, Avda. Isaac Newton nº3, 4ª planta. Parque Tecnológico Cartuja '93, 41092 Sevilla. Teléfono: 955 036 800 - Fax: 955 036 849 http://www.isotrol.com You let a political fight come between you and your best friend you have in all the world. Do you realize how foolish that is? How ominous? How can this country survive if friends can't rise above the quarrel. Constance Hazard, North South (book I) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] passing GET via include
-Original Message- From: Mark Smith [mailto:[EMAIL PROTECTED] Sent: 04 May 2007 08:23 Hello all, Is there a way to allow the passing of variables to included scripts using the GET method, for example includefile.php?name=person; or is there another method of including files that allow you to do this. I have attempted to do this without success, I just get a message saying the file cannot be found. Hi Mark, No, this isn't possible as it makes no sense. When you include a file, you are not performing a request that generates a response - you are simply including the contents of one file in another. When you call include, think of it as just copy/pasting the contents of the included file at that point. Any variables already defined (and in scope) will therefore be be available to the code included file, for example: --- main.php --- $strTitle = 'The title'; $intTitleLength = strlen($strTitle); include('display.php'); --- display.php --- echo 'Title is '.$strTitle.' and is '.$intTitleLength.' characters long'; I hope this makes sense but feel free to reply to the list if you have any questions. Edward -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] passing GET via include
Am Freitag, 4. Mai 2007 09:22 schrieb Mark Smith: Hello all, Is there a way to allow the passing of variables to included scripts See it another way: The includED script will be part of the includING script. ---includeme.inc- ?php $message=Hello!\n; ? ---includer.php-- ?php include('includeme.inc'); echo $message; ? - Will be the same as ---dont_like_inclusions.php--- ?php $message=Hello\n; echo $message; ? --- Regards, Oliver -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] passing GET via include
On 5/4/07, Oliver Block [EMAIL PROTECTED] wrote: Am Freitag, 4. Mai 2007 09:22 schrieb Mark Smith: Hello all, Is there a way to allow the passing of variables to included scripts See it another way: The includED script will be part of the includING script. ---includeme.inc- ?php $message=Hello!\n; ? ---includer.php-- ?php include('includeme.inc'); echo $message; ? - Will be the same as ---dont_like_inclusions.php--- ?php $message=Hello\n; echo $message; ? --- Regards, Oliver Actually, it will be this: ?php ? ?php $message=Hello\n; ? ?php echo $message; ? As you could, for example, include a HTML document :) Tijnema -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] passing GET via include
On Fri, May 4, 2007 2:22 am, Mark Smith wrote: Is there a way to allow the passing of variables to included scripts using the GET method, for example includefile.php?name=person; or is there another method of including files that allow you to do this. I have attempted to do this without success, I just get a message saying the file cannot be found. Well, there's sort of a way to do that. Don't do anything. :-) The variable is already there, waiting for you to use it. You may want to study up on scope however: http://us.php.net/manual/en/language.variables.scope.php If you are in a function, you need to pass $name to that function, or you need to declare it global Passing it in is almost always better. If you just want the original $_GET data, raw and unfiltered, $_GET is a superglobal and you can juse it anywhere, any time. (Ditto for $_POST and all the others) -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php