I was wondering if using defined constants in class definitions
is completely legal (or even good practice) in PHP. I've looked throught the PHP documentation and from what I can
tell it is legal.
However, I've had some problems with Turck MMCache and class definitions
that are similar to above. I suspect that it's probably a bug with MMCache but I wanted to check to make sure that the code was completely
correct.
I also use MMCache, mind sharing the problems you are experiencing?
Here's the situation: PHP 4.3.4 Apache 1.3.29 MMCache 2.4.6
I'm ending up with some garbage in certain class variables. The code runs fine without MMCache disabled.
There seems to be a very specific circumstances under which the error occurs. Namely:
1. The constants must be defined in a seperate file.
2. The member array ($stuff, refer below) must be populated in the class definition, not the class constructor 3. index.php can't be modified after apache has been started. If I touch index.php then the problem disappears, but then if I restart apache the problem reappears.
If you want to see the output of the script go to http://outreach.net.nz/test/
Here's the MMCache configuration: extension="mmcache.so" ;shm_size="0" defaults to the OS default, which is 32M on my system mmcache.shm_size="0" mmcache.cache_dir="/tmp/mmcache" mmcache.enable="1" mmcache.optimizer="1" mmcache.check_mtime="1" mmcache.debug="0" mmcache.filter="" mmcache.shm_max="0" mmcache.shm_ttl="0" mmcache.shm_prune_period="0" mmcache.shm_only="0" mmcache.compress="1"
Here's the code:
index.php
<?php
require_once( "include.php" );
class Yep{
var $stuff = array( HELLO => 'nope', goodbye => 'nah' );
//var $stuff = array();
function Yep(){
/*$this->stuff = array( HELLO => 'nope', goodbye => 'nah' );*/
echo 'yep constructor<br>';
}
function stuff(){
echo '<pre>';
var_dump( $this->stuff );
echo '</pre>';
}
}
$yepper = new Yep();
$yepper->stuff();
echo '<br>';
var_dump( $yepper );
?>
include.php <?php define( 'HELLO', 'hello' ); define( 'goodbye', 'GOODBYE' ); ?>
Thanks for the offer to share. Toro
#####################################################################################
This e-mail message has been scanned for Viruses and Content and cleared by MailMarshal
For more information please visit www.marshalsoftware.com
#####################################################################################
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php