Re: Problems with CONSTANTS that does not get defined - SOLVED

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Me too, until Sven induced me think in the right way about the problem.

I had a validation if-else construction before the execution of
the defines. I knew it had to be a stupid mistake made by me
/somewhere/ - since CONSTANT /should/ work.

But I were unable to track the devil down (been looking for
incorrect spelled variables names, incorrect constant name,
incorrect program logic etc, but got zero...)

The point was that I first wrote the program with hard coded
values in the array indexes - and I generally don't like to
do that - but then found out that PHP support CONSTANTS and
started to introduce them. 


The code worked fine, until it suddenly added some new high
level construction. Of course I did first check the latest
added code, but found nothing, and became quite surprised
while I were nesting down in the call stack trying to locate
the fault - because this was low level function that had been
tested and confirmed to be correct.


What I knew at that point was that some constant had not been
defined, while other was, and I could not for my life understand
why this was the case. Hence I dumped a question to the PHP list
once I confirmed this was the case.

And as in 99,99% of all cases this it turned out to be a silly
mistake overseen by me...


So the reaming mystery for me is now why some constant actually
did work (as I wanted them to) while other did not?



	//Anders - which only been /programing/ php for 2 weeks


On Fri, 2004-03-05 at 13:42, Ignatius Reilly wrote:
> Beats me.
> 
> Ignatius
> _________________________
> ----- Original Message -----
> From: "Svensson, B.A.T. (HKG)" <B.A.T.Svensson@xxxxxxx>
> To: <php-windows@xxxxxxxxxxxxx>
> Sent: Friday, March 05, 2004 13:17
> Subject:  Problems with CONSTANTS that does not get defined
> 
> 
> > Running this code:
> >
> >
> > [...]
> > // META DATA DEFINES
> > define("META_DATA",     -1);
> > define("NUM_LINES",      0);
> > [...]
> > define("JOB_CMD", 5);
> > define("FIVE",    5); // DEBUG
> > [...]
> >
> > function ...()
> > {
> >
> >   $atlist = at_job_list();
> >
> >   $UserJobNr = 0;
> >   $UserJobList[META_DATA][NUM_LINES] = 0;
> >
> >   $numJobs = $atlist[META_DATA][NUM_LINES];
> >
> >   for ($i=1; $i<= $numJobs; $i++) {
> >
> >     // DEBUG START
> >     $test_5        = $atlist[$i][5];
> >     $test_FIVE     = $atlist[$i][FIVE];
> >     $test_JOB_CMD  = $atlist[$i][JOB_CMD];
> >
> >     print "<pre>USER JOB LIST GET/JOB_CMD: /" . $atlist[$i][JOB_CMD] .
> > "/$test_5/$test_FIVE/$test_JOB_CMD</pre>\n";
> >     // DEBUG END
> >
> >     if (user_own_this_job($User, $atlist[$i][JOB_CMD]) ) {
> >       print "<pre>Has job $i</pre>\n"; // DEBUG
> >       $UserJobNr++;
> >       $UserJobList[$UserJobNr] = $atlist[$i];
> >       $UserJobList[$UserJobNr][JOB_UID] = $UserJobNr;
> >     }
> >   }
> >
> > [...]
> >
> >
> > }
> >
> > gives this out put:
> >
> >
> >
> > Warning:  constant(): Couldn't find constant FIVE in [file] on line 238
> >
> > FIVE: FIVE/
> >
> > Warning:  constant(): Couldn't find constant JOB_CMD in [file] on line 239
> >
> > JOB_CMD: JOB_CMD/
> >
> >
> > USER JOB LIST GET/JOB_CMD: //job1 user1//
> >
> > USER JOB LIST GET/JOB_CMD: //job2 user1//
> >
> > USER JOB LIST GET/JOB_CMD: //job1 user2//
> >
> >
> > To say the less, I am a bit confused. Any hints or tips would be
> appreciated.
> >
> > --
> > PHP Windows Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux