Hi all.
I was wondering if using defined constants in class definitions
is completely legal (or even good practice) in PHP.

For example, <?php
define( "CONSTANT", "hello" );
class Yep{
$var stuff = array( CONSTANT => 'two' );
}
?>


I've looked throught the PHP documentation and from what I can
tell it is legal. I'm using PHP4.3.4, and haven't had any problems with class definitions like this.


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.


The following seems to work fine with MMCache,
<?php
define( "CONSTANT", "hello" );
class Yep{
  $var stuff = NULL;
  function Yep(){
     $this->stuff = array( CONSTANT => 'two' );

  }
}
?>

If it turns out that the first example is fine, then I'll look a submitting
a bug for MMCache.

Thanks
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



Reply via email to