Re: HTML calling PHP; PHP returns result
| From: | Frank M. Kromann | Date: | Wed, 18 Apr 2001 14:50:58 +0000 |
| Subject: | Re: HTML calling PHP; PHP returns result | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-6810@lists.php.net to get a copy of this message | ||
In the first script you are trying to call another script. I would jus include the counter script at
that place and have the counter script output the code needed or have a function in the included
script return the output you need.
it would look like this:
<html>
<body>
<?php
include "counter.php";
echo "You are the " . counter_func("XXX", "X") . " visitor";
?>
</body>
</html>
counter.php would look like this:
<?php
function counter_func($App, $Trailer="")
{
// Do the counting stuff
return $theresult;
}
?>
In this function the $Trailer is made optional with a default value of an empty string.
- Frank
> I'm developing a reusable PHP hit counter. Is the following the correct way
> to accomplish this function?
>
>
> This HTML module is in one directory ...
>
> <html>
> <body>
> You are the
>
> <? ../cgi-bin/counter.php?$App="xxx"?$Trailer="X"; ?>
>
> visitor.
>
> </body>
> </html>
>
> All the above does is calls counter.php with the application's name and
> whether a trailer is desired. It is supposed to
> return "1st", "2nd", "3rd", "4th" ..... etc. to be
> displayed within the
> "You are ...." string.
>
> This PHP module resides in cgi-bin ...
>
> <?
> // I am counter.php
>
> do the file I/O stuff using $App and $Trailer
>
> return $theresult
>
> ?>
>
> All the above does is reads the application's hit counter file (creates one
> if not found) and sends the text back to the
> calling HTML module.
>
>
>
>