RE: [PHP] Global Constants
| From: | Mark Olbert | Date: | Thu, 28 Sep 2000 02:02:08 +0000 |
| Subject: | RE: [PHP] Global Constants | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-17840@lists.php.net to get a copy of this message | ||
Mike,
Nope, that didn't work. But it made me think of something that appears to
work (have to check it on my whole site, not just one file):
In the class.php file:
<script language="php">
global $include_classname;
if( !isset($include_classname) ) {
$include_classname = 1;
... rest of file
} // endif for ifdefined
</script>
In other words, using a global variable, rather than a constant, seems to do
the trick.
Thanx for your help!
- Mark
-----Original Message-----
From: Mike Glover [mailto:mpg4@duluoz.net]
Sent: Wednesday, September 27, 2000 6:33 PM
To: Mark Olbert; php-general@lists.php.net
Subject: Re: [PHP] Global Constants
Mark-
This is what I do, and it works for me:
<?php
if ( ! defined (INCLUDE_FILENAME) ) :
define (INCLUDE_FILENAME, 1);
[contents of file go here]
endif;
?>
Two differences between mine and yours. One, I use the <?php ?>
tags instead of the <script></script> tags. Two, I'm ifdef'ing
out the entire contents of the file, you're trying to call
return after checking the include flag.
Some debugging thoughts. Have you tried including a file twice
within the same section of code? Have you tried an include file
that just echoes it's filename?
-mike
On Wed, 27 Sep 2000, Mark Olbert wrote:
>
> <script language="php">
> $include_flag = "INCLUDE" . basename(__FILE__);
>
> if( defined($include_flag) ) {
> return TRUE;
> }
>
> define($include_flag, TRUE);
>
> .... rest of dbclass.php file
>
> main phtml file:
> ....
>
> <div class="one">
> ....
> <script language="php">
> include("dbclass.php");
> ...
> </script>
> </div>
> ....
> <div class="two">
> ....
> <script language="php">
> include("dbclass.php"); <----- error generated; duplicate include
>
>
> Apparently, the defined constants don't "survive" from one <script> to
> the
> next.
>
> Does anyone know of a solution to this problem? Other than (a) not having
> separate <scrip> fragments or (b) just commenting out the second
> include()
> [that's what I'm doing now, but I'd like to avoid it because it
> introduces a
> dependency into the code].
>
> Thanx in advance for any help or advice!
>
> - Mark
> mark@REMOVETHIS STUFF@arcabama.com
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>
--
"don't you know about the new fashion, honey?
all you need are looks and a whole lotta money"
-- billy joel
GnuPG key available at http://devel.duluoz.net/pubkey.asc
Key ID = 1024D/9A256AE5 1999-11-13 Mike Glover <mpg4@duluoz.net>
Key fingerprint = EF6E 8BCB 4810 E98C F0FD 4596 367A 32B7 9A25 6AE5