|
Posted by Jim Carlock on 02/01/06 00:42
How do I get a function to see a global variable without employing
a parameter list?
The source code:
<html><head>
<title>Simple Global Variable / Function Test</title>
<?php
$counter_file = "counter.txt"; // global variable
//quickquote function
function qq($sQuoteMe, $sQuoteChar) {
return("$sQuoteChar$sQuoteMe$sQuoteChar");
}
function updatecount() {
echo('<p>$counter_file = ' . "$counter_file</p>\n");
}
?>
</head>
<body><?php
echo('<p>$counter_file = ' . qq($counter_file, """) . "</p>\n");
// echo('Hits: ' . qq("qq test", '"'));
echo('<p>Hits: ' . qq(updatecount(), """) . "</p>\n");
?></body></html>
... echos the following HTML to the browser ...
<html><head>
<title>Simple Global Variable / Function Test</title>
</head>
<body><p>$counter_file = "counter.txt"</p>
<p>Hits: ""</p>
</body></html>
Thanks.
Jim Carlock
Post replies to the newsgroup.
P.S. (For the people at php.net)...
The Zend Optimizer link on this page results in a 404 page. Search for
"Zend Optimizer" on the following page:
http://us3.php.net/downloads.php
Navigation:
[Reply to this message]
|