473,326 Members | 2,680 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

global variables, Apache, PHP4.4.1Win32, WinXP

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, "&quot;") . "</p>\n");
// echo('Hits: ' . qq("qq test", '&quot;'));
echo('<p>Hits: ' . qq(updatecount(), "&quot;") . "</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 = &quot;counter.txt&quot;</p>
<p>Hits: &quot;&quot;</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
Feb 1 '06 #1
3 1818
I put my vote in for the

Option Explicit '(.asp/vbscript) (use strict //perl)

as a requested improvement.

http://bugs.php.net/bug.php?id=14285&thanks=6

Only 17 votes there right at the moment. If anyone else would like
such an improvement, go to the link above and vote.

Jim Carlock
Post replies to the newsgroup.
Feb 1 '06 #2
Al

Jim Carlock wrote:
I put my vote in for the

Option Explicit '(.asp/vbscript) (use strict //perl)

as a requested improvement.

http://bugs.php.net/bug.php?id=14285&thanks=6

Only 17 votes there right at the moment. If anyone else would like
such an improvement, go to the link above and vote.

Jim Carlock
Post replies to the newsgroup.


Well if you set your error level thingy to E_ALL it'll throw a notice
if you use a variable that you haven't instantiated. But instantiation
basically means 'setting'. So you can do this code:

<?php

$counter = 3;

$countr = $counter + 1; // notice the error (and i only didn't use
$countr++ because that might actually throw the notice)

echo $counter;

?>

and it won't throw a notice as you're using the NEW $countr variable in
a setting sense. However it does help you a little with regards to
CHECKING a variable, e.g.:

<?php

$counter = 3;

echo $countr;

?>

that should throw a notice with errors at E_ALL.

But that's nowhere near a nice Option Explicit.

Feb 1 '06 #3
Al
Al wrote:
Well if you set your error level thingy to E_ALL it'll throw a notice
if you use a variable that you haven't instantiated. But instantiation
basically means 'setting'.


Heh just read that page you linked to and it's totally explained there.
Probably better than I did too.

Feb 1 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Seagull Manager | last post by:
Running Apache 1.3, PHP 4.3, and WinXP, configured acc. to instructions on apache manual and php manual (as far as I can see), but getting "internal server error" in browser... log says "Premature...
2
by: Johan den Boer | last post by:
Hi, Tried installation with apache 2.0.47. But nothing is working. Copied all the dll's and .ini file to the right locations. Changed the httpd.conf file as well. Here is what I added in...
4
by: Krista | last post by:
Hi everybody, I think my confi has some problems. Can you guys help me to see what is going on? i install Apache2.0.48 and Php4.3.4 in WinXP. I add some codes in httpd(inside apache...
1
by: dave | last post by:
Hello, I have a very urgent problem! The situation is i have an rh 7.1 box, i know it's not mine though, that has apache 1.3.27 on it in the form of what i presume is an rpm, it's actually on a...
4
by: jimt | last post by:
what am i looking for. what libraries do i need to locate? etc... other than putting severe dents in my head and desk i dont seem to be making any headway. the libraries are so different from...
0
by: Dave Pham | last post by:
I just cleaned my comp, and I am trying to re-config my webserver... I am trying to setup apache 2 so it runs both php4 and php5, I also have two instances of mysql running. I know this can be...
3
by: 99m | last post by:
I used to have Apache and PHP4 working perfectly in Ubuntu Hoary Linux. I upgraded to Ubuntu Breezy Linux and I either get one of the following problems: "You don't have permission to access...
5
by: sinister | last post by:
I'm starting a database/web interface project, using Linux and postgresql. I've programmed in PHP4 in the past, and for this new project am unsure whether to use PHP4 or PHP5. My main concerns...
7
by: jrefran | last post by:
Hi Everyone! Is there a need to compile my Apache 2.0.59 if I will use PHP4.4.5? How can I apply my Apache to PHP4.4.5 or I might ask how will I use my Apache properly with PHP4.4.5? This is...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.