Re: [PHP4BETA] implement assert() function?

From: Date: Tue, 07 Dec 1999 15:25:13 +0000
Subject: Re: [PHP4BETA] implement assert() function?
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-7606@lists.php.net to get a copy of this message
On Tue, 7 Dec 1999, Andrei Zmievski wrote: > On Tue, 07 Dec 1999, Thies C . Arntzen wrote: > > hi, > > just thought of implemention an assert() function together with some > > helpers: > > > > - some .ini flags > > - an assert_set_options() function (ON/OFF, EXIT_ON_FAILURE etc) > > - maybe a script-settable logging function (called with __LINE__ ...) > > > > what do we think? > > > > Hey, I was just thinking about something like this, but I was going to > implement it in PHP itself. I mean it's fairly easy to write it. thought about tthat one myself.... doesn't work: no, cause you cannot get the correct __FILE__ and __LINE__ if you implement it in php! also i implemented dynamic evauation of the expression: assert_options(ASSERT_ACTIVE,1); assert(0); assert('count($hallo) == 0'); // if ASSERT_ACTIVE is 0 this will NOT be evaluated! i see if i can write the docs later today... also see: <? function myassert($fname,$lineno,$myeval) { printf("\nmyassert failed in $fname:$lineno \"$myeval\"\n"); } assert_options(ASSERT_CALLBACK,"myassert"); assert_options(ASSERT_BAIL,1); assert_options(ASSERT_WARNING,1); $entries=array(); assert('count($entries) == 1'); assert('$a == 0'); ?> > > I don't know if you'd need logging or not, we already have a function > for that. > > -Andrei > * We reason deeply, when we forcibly feel. * > > Thies C. Arntzen "One Big-Mac, Small Fries and a Coke!" Digital Collections Phone +49 40 235350 Fax +49 40 23535180 Hammerbrookstr. 93 20097 Hamburg / Germany

« previous php.version4 (#7606) next »