473,396 Members | 2,009 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

defined() doesn't work correctly

Hi,

I'm using this function:

function die_quietly( $text='', $title='', $file='', $line='', $sql='' )
{
global $wowdb, $roster_conf, $wordings, $roster_menu;

// die_quitely died quietly
if (defined(ROSTER_DIED))
{
print '<pre>The quiet die function suffered a fatal error.
Die information below'."\n";
print 'First die data:'."\n";
print_r($GLOBALS['die_data']);
print "\n".'Second die data'."\n";
print_r(func_get_args());
exit();
}

define(ROSTER_DIED,1);

$GLOBALS['die_data'] = func_get_args();

// Snip stuff that generates a graphical error page

exit();
}

The purpose of this function is creating a graphical error page if
something in my package causes a fatal error, rather than just dying.
The purpose of the quoted part is preventing undesired recursion if
something inside the die_quietly() function calls the die_quietly()
function again.

This code however doesn't work correctly. defined(ROSTER_DIED) seems to
return false on the second function call, and return true on the third.
Which means it returns the reason die_quietly failed twice, but not the
reason die_quietly was originally called.

Can anyone explain to me why this happens?
--
PleegWat
Remove caps to reply
Nov 2 '06 #1
2 1957
define(ROSTER_DIED,1);
According to the PHP Manual, your first argument must be a string. ie:
define('ROSTER_DIED', 1);
Then you can refer to it without the quotes (ie $this = ROSTER_DIED)
if (defined(ROSTER_DIED))
This should also be a string ie: defined('ROSTER_DIED')

See if that helps.

Nov 2 '06 #2
In article <11**********************@h54g2000cwb.googlegroups .com>,
ad*******@gmail.com says...
define(ROSTER_DIED,1);
According to the PHP Manual, your first argument must be a string. ie:
define('ROSTER_DIED', 1);
Then you can refer to it without the quotes (ie $this = ROSTER_DIED)
if (defined(ROSTER_DIED))
This should also be a string ie: defined('ROSTER_DIED')

See if that helps.
Yes, that worked.
--
PleegWat
Remove caps to reply
Nov 3 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: teddysnips | last post by:
In the script below is the DDL to create some tables and a UDF. What I'm interested in is the UDF at the end. Specifically, these few lines: --CLOSE OTRate --DEALLOCATE OTRate ELSE --...
149
by: Christopher Benson-Manica | last post by:
(Followups set to comp.std.c. Apologies if the crosspost is unwelcome.) strchr() is to strrchr() as strstr() is to strrstr(), but strrstr() isn't part of the standard. Why not? --...
1
by: Oodini | last post by:
Hello, Could anyone explain me the following preprocessor sentences: ---------------------------------------------------------------- #if (defined(__STDC__) && !defined(NO_PROTOTYPE)) ||...
6
by: A.M-SG | last post by:
Hi, I have an aspx page at the web server that provides PDF documents for smart client applications. Here is the code in aspx page that defines content type: Response.ContentType =...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
6
by: karthi | last post by:
hi, I need user defined function that converts string to float in c. since the library function atof and strtod occupies large space in my processor memory I can't use it in my code. regards,...
6
by: Johnny Jörgensen | last post by:
I've got a usercontrol derived from a normal ComboBox that contains some special formatting code. On my main form I've got a lot of my custom comboboxes. I discovered a bug in the derived...
4
by: Andrew Poulos | last post by:
I'm trying to use the String method parseJSON (that is created in the javascript of a frameset) in one of the frames but I don't know how to correctly reference it. This: notes =...
39
by: alex | last post by:
I've converted a latin1 database I have to utf8. The process has been: # mysqldump -u root -p --default-character-set=latin1 -c --insert-ignore --skip-set-charset mydb mydb.sql # iconv -f...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.