473,796 Members | 2,903 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

My mind is going? empty($_SESSION["not_there"])

I thought that the given expression was always TRUE if "not_there"
wasn't among the keys (or subscripts if you will) of $_SESSION.

Below find a dump of $_SESSION, a small snippet of code and the results.
I really don't understand. A new pair of eyes may be able to spot what
should be an obvious bug.

Thanks for looking.

_SESSION=array 16 { userid=>bob; setname=>Junk_C ows; setuser=>jhough ;
setid=>Junk_Cow s.jhough; locid=>11111111 1; maxloc=>1111111 11; empid=>1;
personal_id=>10 724; administrator=> ; locname=>Benysh ek-Hough; left=>1;
right=>1152; emp_left=>1; emp_right=>1152 ; uses_eid=>Y; bhid=>292550; }

$debug .= "<br>date 1=$date; <br>";
if(empty($date) ) {
$debug .= "<br>date 2=$date; <br>";
if(empty($_SESS ION["sale_date"])) {
$date = date("m-d-Y");
$debug .= "<br>date 3=$date; <br>";
}
else {
$date = $_SESSION["sale_date"];
$debug .= "<br>date 4=$date; <br>";
}
}
$_SESSION["sale_date"] = $date;
$debug .= "<br>date 5=$date; <br>";

date 1=;

date 2=;

date 4=2;

date 5=2;
Dec 19 '05 #1
2 2022
In article <ep************ *****@fe02.lga> , Bob Stearns
<rs**********@c harter.net> wrote:
I thought that the given expression was always TRUE if "not_there"
wasn't among the keys (or subscripts if you will) of $_SESSION.


I would always use:

if (isset($_SESSIO N['not_there'])) {

}

or

if (array_key_exis ts('not_there', $_SESSION)) {

}

in your case.

Try if that works better. I only use empty($var) when I am certain that
$var exists. (Note: I didn't follow your code step by step, so this may
be useless advice.)

JP
Dec 19 '05 #2
Bob Stearns wrote:
I thought that the given expression was always TRUE if "not_there"
wasn't among the keys (or subscripts if you will) of $_SESSION.

Below find a dump of $_SESSION, a small snippet of code and the results.
I really don't understand. A new pair of eyes may be able to spot what
should be an obvious bug.


For me, all the following give the same results: bool(true)

<?php
$ar=array('this '=>3);
var_dump(empty( $ar['that']));

$ar=array('this '=>'');
var_dump(empty( $ar['this']));

$ar=array('this '=>array());
var_dump(empty( $ar['this']));

$ar=array('this '=>NULL);
var_dump(empty( $ar['this']));

$ar=array('this '=>0);
var_dump(empty( $ar['this']));

$ar=array('this '=>'0');
var_dump(empty( $ar['this']));

$ar=array('this '=>FALSE);
var_dump(empty( $ar['this']));
?>

However, I never use empty($var) alone, I usually use variations like:
(!isset($var) || empty($var)) // not set or empty
(isset($var) && empty($var)) // set & empty
(isset($var) && !empty($var)) // set & not empty

--
Justin Koivisto, ZCE - ju****@koivi.co m
http://koivi.com
Dec 19 '05 #3

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

Similar topics

1
2207
by: Arthur T. Murray | last post by:
"Bill Modlin" <modlin1@metrocast.net> wrote on Fri, 26 Sep 2003: <snip> >>> If I wanted to explain how one of my programs worked >>> I would not give someone a print out of the code. >>> First I would explain it in higher level (folk psychology?) >>> terms and then explain how I embodied these ideas in actual code. >> I'm not sure why - especially if the person you're explaining it to >> is a programmer and knows the language. BM:
11
2569
by: Arthur T. Murray | last post by:
Now, suppose that you wanted to write an AI in Python that would implement your mind-model and allow it to grow, mutate, develop. Here is one possible scenario. It would not be necessary to do all the work yourself. If we began coding a baby Mind.py and published the initial code out on the Web, other Python programmers might start adding to it and start specializing in the refinement of hotspots. ...
42
2057
by: Mike P. | last post by:
Hello I come from the world of C++ programming, and I'm used to writing programs that are actually executed by the CPU, and that run with some semblance of performance. I have taken the time to explore this .NET thing, and found that not only do .NET applications run extremely s-l-o-w-l-y, but the various .NET languages amount to nothing more than interpreted script languages. It is the common language run-time that actually executes your...
8
1676
by: Steve | last post by:
I notice that search engines are now finding robots.txt files and catalogue their contents. Is this wise I wonder? Is it a possible security risk? I even found the White House robots.txt file on Google. Surely disclosing detains of the directory structure is an open invitation for hackers to 'take a look'? Does anyone else feel the same way? Should we be bringing this to the search engines attention?
0
277
by: Normie Smith | last post by:
Hello... I have a strange situation happening, and I thought maybe I could get some assistance. I have created a simple user control (.ascx) file that's part of my default.aspx page. The user control contains a link button control, such as: <asp:LinkButton id="idLinkButtonopenAll" runat="server">open all</asp:LinkButton> Then in my code-behind file, I have it's event handler, such as:
14
3474
by: vatamane | last post by:
This has been bothering me for a while. Just want to find out if it just me or perhaps others have thought of this too: Why shouldn't the keyset of a dictionary be represented as a set instead of a list? I know that sets were introduced a lot later and lists/dictionaries were used instead but I think "the only correct way" now is for the dictionary keys and values to be sets. Presently {1:0,2:0,3:0}.keys() will produce but it could also...
11
2211
by: Wayne | last post by:
I am a one man enterprise and have been asked by a prospective client what happens to their database regarding ongoing changes etc if I get hit by a bus. Obviously my databases are distributed as mde files in an effort to protect my intellectual property. How do I give the client peace of mind, short of giving them a backup mdb file that any programmer could work on to provide required changes etc if I wasn't around? Of course this...
2
1485
by: Deac | last post by:
I have two Access 2003 tables, one has a "Zone" and "Lot1SqFt" that changes with each record. (8,000+ records) A portion of this table: CustomerID ZONE Lot1SqFt SqFtPrice TotalPrice 21 2 27100 $1,599.00 $1,979.00 37 4 15475 $1,068.00 $1,392.00 366 1 17190 $1,187.00 $1,292.00
0
9679
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9527
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10453
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10223
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10003
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9050
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7546
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6785
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.