[thelist] Global variables in functions?

Ralph Guzman ralph at nqionline.com
Wed Aug 20 00:55:45 CDT 2003


This should do it:

$url = 'http://server/script.php?'.$_SERVER[QUERY_STRING];
$output = file_get_contents ($url)

function body($output){
  if(!$output){
     return false;
  } else { 
     echo $output;
  }
}

-----Original Message-----
From: thelist-bounces at lists.evolt.org
[mailto:thelist-bounces at lists.evolt.org] On Behalf Of Joel Konkle-Parker
Sent: Tuesday, August 19, 2003 9:48 PM
To: thelist at lists.evolt.org
Subject: [thelist] Global variables in functions?

This looks like something very fundamental that I'm just not
understanding...

I have a PHP script that declares some variables and a body() function,
then
includes a template script that integrates body() and prints the page.

When I do this:

--
  $url = 'http://server/script.php?'.$_SERVER[QUERY_STRING];
  $output = file_get_contents ($url);

function body() {
  echo $output;
}
--

body() ends up empty. But when I do this:

--
function body() {

  $url = 'http://server/script.php?'.$_SERVER[QUERY_STRING];
  $output = file_get_contents ($url);
  echo $output;

}
--

it works fine.

The ultimate goal here is to read the resulting page from $url, strip
off
everything but the contents of <body></body>, and print the result.

What am I missing here?

(btw, any tips on the line-stripping?)


--
Joel Konkle-Parker
Webmaster [Ballsome.com]

Phone     [662-518-1636]
E-mail    [jjk3 at msstate.edu]
-- 
* * Please support the community that supports you.  * *
http://evolt.org/help_support_evolt/

For unsubscribe and other options, including the Tip Harvester 
and archives of thelist go to: http://lists.evolt.org 
Workers of the Web, evolt ! 




More information about the thelist mailing list