[PHP] Re: isset empty or ...?

2013-03-31 Thread Jim Giner

On 3/31/2013 12:53 AM, John Taylor-Johnston wrote:

I'm using

if($mydata-DPRresponselocationaddress1 != )

is this the same as

if (!isset($mydata-DPRresponselocationaddress))
http://php.net/manual/en/function.isset.php

or

if (!empty($mydata-DPRresponselocationaddress))
http://php.net/manual/en/function.empty.php

or is there another function I have not learned yet? I don't really get
the difference between isset and empty.

John
The simple answer is that isset is supposed to tell you if a var has 
been created; a test for  is looking for a value of a var.  While 
sometimes the results can be the same (and therefore confusing) that is 
what the two provide.  How you use them is dependent on your 
understanding of PHP and the task before you.


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



[PHP] Re: isset question

2009-06-18 Thread Gary
This is what I have now and it works. I do know that on the second line I 
have $_POST['mort']}\n :  ; in the second half. I'm not sure I understand 
the comment about use the !empty if you dont care about PHP.

But this is working, and unless someone sees a problem with it, I will leave 
it as is.

Thank you to everyone for helping.

Gary


$msg.=  !empty($_POST['purchprice']) ? If this information is completed, it 
is a new purchase.\n The Purchase Price is  $purchprice\n :  ;
$msg.=  !empty($_POST['mort']) ? The mortgage amount is 
{$_POST['mort']}\n :  ;
$msg.=  !empty($_POST['howlong']) ? The sellers have owned the property for 
$howlong\n\n\n :  ;

$msg.=  !empty($_POST['mortgage']) ? If this information is completed, it 
is a refinance.\nThe mortgage amount  is  $mortgage\n :  ;
$msg.=  !empty($_POST['purdate']) ? The property was originally purchased 
on  $purdate\n :  ;
$msg.=  !empty($_POST['datefin']) ? The property was last financed 
$datefin\n :  ;


Gary gwp...@ptd.net wrote in message 
news:ea.e8.08167.6ac8a...@pb1.pair.com...
I have a form that gives the submitter a choice or either one set of 
questions, or another. I am still getting the message even if the input was 
left blank.  So on the line below,

 $msg.=  isset($_POST['mort']) ? The mortgage amount is  $mort\n :  ;

 I get

 The mortgage amount is

 What am I missing here?

 Thanks

 Gary
 



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



Re: [PHP] Re: isset question

2009-06-18 Thread LAMP

Gary wrote:
This is what I have now and it works. I do know that on the second line I 
have $_POST['mort']}\n :  ; in the second half. I'm not sure I understand 
the comment about use the !empty if you dont care about PHP.
  

 if you don't care about PHP Notice... 

eror_reporting:
http://us.php.net/manual/en/function.error-reporting.php
http://us.php.net/manual/en/errorfunc.constants.php#errorfunc.constants.errorlevels.e-notice

put error_reporting(E_ALL) on the begining of you page you will get 
errors, warnings and notices - if any.
errors and warnings stop the execution of the code. notice not. notices 
are usually about not defined variables before you started to use them.


if you put error_reporting(E_ALL ^ E_NOTICE) it will not bother you. but 
I like to do everything correctly. :-)


afan



But this is working, and unless someone sees a problem with it, I will leave 
it as is.


Thank you to everyone for helping.

Gary


$msg.=  !empty($_POST['purchprice']) ? If this information is completed, it 
is a new purchase.\n The Purchase Price is  $purchprice\n :  ;
$msg.=  !empty($_POST['mort']) ? The mortgage amount is 
{$_POST['mort']}\n :  ;
$msg.=  !empty($_POST['howlong']) ? The sellers have owned the property for 
$howlong\n\n\n :  ;


$msg.=  !empty($_POST['mortgage']) ? If this information is completed, it 
is a refinance.\nThe mortgage amount  is  $mortgage\n :  ;
$msg.=  !empty($_POST['purdate']) ? The property was originally purchased 
on  $purdate\n :  ;
$msg.=  !empty($_POST['datefin']) ? The property was last financed 
$datefin\n :  ;



Gary gwp...@ptd.net wrote in message 
news:ea.e8.08167.6ac8a...@pb1.pair.com...
  
I have a form that gives the submitter a choice or either one set of 
questions, or another. I am still getting the message even if the input was 
left blank.  So on the line below,


$msg.=  isset($_POST['mort']) ? The mortgage amount is  $mort\n :  ;

I get

The mortgage amount is

What am I missing here?

Thanks

Gary






  



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



Re: [PHP] Re: isset question

2009-06-18 Thread Martin Scotta
error_reporting( E_ALL | E_STRICT );

if you want to be extremely sure about your app (only in develop)

On Thu, Jun 18, 2009 at 5:04 PM, LAMP l...@afan.net wrote:

 Gary wrote:

 This is what I have now and it works. I do know that on the second line I
 have $_POST['mort']}\n :  ; in the second half. I'm not sure I understand
 the comment about use the !empty if you dont care about PHP.


  if you don't care about PHP Notice... 

 eror_reporting:
 http://us.php.net/manual/en/function.error-reporting.php

 http://us.php.net/manual/en/errorfunc.constants.php#errorfunc.constants.errorlevels.e-notice

 put error_reporting(E_ALL) on the begining of you page you will get errors,
 warnings and notices - if any.
 errors and warnings stop the execution of the code. notice not. notices are
 usually about not defined variables before you started to use them.

 if you put error_reporting(E_ALL ^ E_NOTICE) it will not bother you. but I
 like to do everything correctly. :-)

 afan




  But this is working, and unless someone sees a problem with it, I will
 leave it as is.

 Thank you to everyone for helping.

 Gary


 $msg.=  !empty($_POST['purchprice']) ? If this information is completed,
 it is a new purchase.\n The Purchase Price is  $purchprice\n :  ;
 $msg.=  !empty($_POST['mort']) ? The mortgage amount is
 {$_POST['mort']}\n :  ;
 $msg.=  !empty($_POST['howlong']) ? The sellers have owned the property
 for $howlong\n\n\n :  ;

 $msg.=  !empty($_POST['mortgage']) ? If this information is completed, it
 is a refinance.\nThe mortgage amount  is  $mortgage\n :  ;
 $msg.=  !empty($_POST['purdate']) ? The property was originally purchased
 on  $purdate\n :  ;
 $msg.=  !empty($_POST['datefin']) ? The property was last financed
 $datefin\n :  ;


 Gary gwp...@ptd.net wrote in message
 news:ea.e8.08167.6ac8a...@pb1.pair.com...


 I have a form that gives the submitter a choice or either one set of
 questions, or another. I am still getting the message even if the input was
 left blank.  So on the line below,

 $msg.=  isset($_POST['mort']) ? The mortgage amount is  $mort\n :  ;

 I get

 The mortgage amount is

 What am I missing here?

 Thanks

 Gary










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




-- 
Martin Scotta


Re: [PHP] Re: isset question

2009-06-18 Thread LAMP

Martin Scotta wrote:

error_reporting( E_ALL | E_STRICT );

if you want to be extremely sure about your app (only in develop)

Actually, I use error_reporting(E_ALL) while developing
:-)

Afan




On Thu, Jun 18, 2009 at 5:04 PM, LAMP l...@afan.net 
mailto:l...@afan.net wrote:


Gary wrote:

This is what I have now and it works. I do know that on the
second line I have $_POST['mort']}\n :  ; in the second
half. I'm not sure I understand the comment about use the
!empty if you dont care about PHP.
 


 if you don't care about PHP Notice... 

eror_reporting:
http://us.php.net/manual/en/function.error-reporting.php

http://us.php.net/manual/en/errorfunc.constants.php#errorfunc.constants.errorlevels.e-notice

put error_reporting(E_ALL) on the begining of you page you will
get errors, warnings and notices - if any.
errors and warnings stop the execution of the code. notice not.
notices are usually about not defined variables before you started
to use them.

if you put error_reporting(E_ALL ^ E_NOTICE) it will not bother
you. but I like to do everything correctly. :-)

afan




But this is working, and unless someone sees a problem with
it, I will leave it as is.

Thank you to everyone for helping.

Gary


$msg.=  !empty($_POST['purchprice']) ? If this information is
completed, it is a new purchase.\n The Purchase Price is
 $purchprice\n :  ;
$msg.=  !empty($_POST['mort']) ? The mortgage amount is
{$_POST['mort']}\n :  ;
$msg.=  !empty($_POST['howlong']) ? The sellers have owned
the property for $howlong\n\n\n :  ;

$msg.=  !empty($_POST['mortgage']) ? If this information is
completed, it is a refinance.\nThe mortgage amount  is
 $mortgage\n :  ;
$msg.=  !empty($_POST['purdate']) ? The property was
originally purchased on  $purdate\n :  ;
$msg.=  !empty($_POST['datefin']) ? The property was last
financed $datefin\n :  ;


Gary gwp...@ptd.net mailto:gwp...@ptd.net wrote in
message news:ea.e8.08167.6ac8a...@pb1.pair.com...
 


I have a form that gives the submitter a choice or either
one set of questions, or another. I am still getting the
message even if the input was left blank.  So on the line
below,

$msg.=  isset($_POST['mort']) ? The mortgage amount is
 $mort\n :  ;

I get

The mortgage amount is

What am I missing here?

Thanks

Gary

   





 




-- 
PHP General Mailing List (http://www.php.net/)

To unsubscribe, visit: http://www.php.net/unsub.php




--
Martin Scotta



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



[PHP] Re: isset($a-b) even if $a-b = null

2007-08-17 Thread Colin Guthrie
Olav Mørkrid wrote:
 how do i test if a property of a stdclass object is set, even if its
 value is null, similar to how array_key_exists() works for arrays.
 
 the following method fails:
 
   $a-b = null;
   if(isset($a-b))
 echo yes;
 
 and property_exists() seems only to work for defined objects.
 
 hope someone can help. thanks!

You can try:
 unset($a-b)

Or change isset() to empty().

empty() catches more than isset() e.g. '' (empty string), false, 0 etc.
are considered empty. Depending on your logic it can still be very
useful. It is a language construct rather than a function so it's also
efficient.

Col

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



Re: [PHP] Re: isset($a-b) even if $a-b = null

2007-08-17 Thread Olav Mørkrid
the solution has been found. array_key_exists() can actually be used
on objects, and yields the correct result.

http://no.php.net/array_key_exists

thanks to dordea cosmin for pointing this out.

On 17/08/07, Olav Mørkrid [EMAIL PROTECTED] wrote:
 the test i need should give the following results:

 - FALSE when $a-b does not exist at all
 - TRUE when $a-b = null
 - TRUE when $a-b = any value

 empty() gives true for both $a-b = null and not setting any value, so
 that's no good.

 borokovs suggestion seems to miss the purpose.

 anyone else?

 On 17/08/07, Colin Guthrie [EMAIL PROTECTED] wrote:
  Olav Mørkrid wrote:
   how do i test if a property of a stdclass object is set, even if its
   value is null, similar to how array_key_exists() works for arrays.
  
   the following method fails:
  
 $a-b = null;
 if(isset($a-b))
   echo yes;
  
   and property_exists() seems only to work for defined objects.
  
   hope someone can help. thanks!
 
  You can try:
   unset($a-b)
 
  Or change isset() to empty().
 
  empty() catches more than isset() e.g. '' (empty string), false, 0 etc.
  are considered empty. Depending on your logic it can still be very
  useful. It is a language construct rather than a function so it's also
  efficient.
 
  Col
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 


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



Re: [PHP] Re: isset($a-b) even if $a-b = null

2007-08-17 Thread Michael Preslar
Found something.

For class variables..

http://us.php.net/manual/en/function.property-exists.php

class a {
  var $b;
}

if (property_exists('a','b')) {
  print yes\n;
}


On 8/17/07, Olav Mørkrid [EMAIL PROTECTED] wrote:
 the test i need should give the following results:

 - FALSE when $a-b does not exist at all
 - TRUE when $a-b = null
 - TRUE when $a-b = any value

 empty() gives true for both $a-b = null and not setting any value, so
 that's no good.

 borokovs suggestion seems to miss the purpose.

 anyone else?

 On 17/08/07, Colin Guthrie [EMAIL PROTECTED] wrote:
  Olav Mørkrid wrote:
   how do i test if a property of a stdclass object is set, even if its
   value is null, similar to how array_key_exists() works for arrays.
  
   the following method fails:
  
 $a-b = null;
 if(isset($a-b))
   echo yes;
  
   and property_exists() seems only to work for defined objects.
  
   hope someone can help. thanks!
 
  You can try:
   unset($a-b)
 
  Or change isset() to empty().
 
  empty() catches more than isset() e.g. '' (empty string), false, 0 etc.
  are considered empty. Depending on your logic it can still be very
  useful. It is a language construct rather than a function so it's also
  efficient.
 
  Col
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 

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



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



Re: [PHP] Re: isset($a-b) even if $a-b = null

2007-08-17 Thread Olav Mørkrid
yes, but that assumes you have a defined class. if $a comes from
mysql_fetch_object() for instance you have just a stdobject, and this
method will produce an error.

On 17/08/07, Michael Preslar [EMAIL PROTECTED] wrote:
 Found something.

 For class variables..

 http://us.php.net/manual/en/function.property-exists.php

 class a {
   var $b;
 }

 if (property_exists('a','b')) {
   print yes\n;
 }


 On 8/17/07, Olav Mørkrid [EMAIL PROTECTED] wrote:
  the test i need should give the following results:
 
  - FALSE when $a-b does not exist at all
  - TRUE when $a-b = null
  - TRUE when $a-b = any value
 
  empty() gives true for both $a-b = null and not setting any value, so
  that's no good.
 
  borokovs suggestion seems to miss the purpose.
 
  anyone else?
 
  On 17/08/07, Colin Guthrie [EMAIL PROTECTED] wrote:
   Olav Mørkrid wrote:
how do i test if a property of a stdclass object is set, even if its
value is null, similar to how array_key_exists() works for arrays.
   
the following method fails:
   
  $a-b = null;
  if(isset($a-b))
echo yes;
   
and property_exists() seems only to work for defined objects.
   
hope someone can help. thanks!
  
   You can try:
unset($a-b)
  
   Or change isset() to empty().
  
   empty() catches more than isset() e.g. '' (empty string), false, 0 etc.
   are considered empty. Depending on your logic it can still be very
   useful. It is a language construct rather than a function so it's also
   efficient.
  
   Col
  
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
  
  
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 


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



Re: [PHP] Re: isset($a-b) even if $a-b = null

2007-08-17 Thread Olav Mørkrid
the test i need should give the following results:

- FALSE when $a-b does not exist at all
- TRUE when $a-b = null
- TRUE when $a-b = any value

empty() gives true for both $a-b = null and not setting any value, so
that's no good.

borokovs suggestion seems to miss the purpose.

anyone else?

On 17/08/07, Colin Guthrie [EMAIL PROTECTED] wrote:
 Olav Mørkrid wrote:
  how do i test if a property of a stdclass object is set, even if its
  value is null, similar to how array_key_exists() works for arrays.
 
  the following method fails:
 
$a-b = null;
if(isset($a-b))
  echo yes;
 
  and property_exists() seems only to work for defined objects.
 
  hope someone can help. thanks!

 You can try:
  unset($a-b)

 Or change isset() to empty().

 empty() catches more than isset() e.g. '' (empty string), false, 0 etc.
 are considered empty. Depending on your logic it can still be very
 useful. It is a language construct rather than a function so it's also
 efficient.

 Col

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



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



Re: [PHP] Re: isset($a-b) even if $a-b = null

2007-08-17 Thread Borokov Smith

Maybe if you tell us exactly what you wish to achieve.
Class variables that are not created at object creation is bad design.

Olav Mørkrid schreef:

yes, but that assumes you have a defined class. if $a comes from
mysql_fetch_object() for instance you have just a stdobject, and this
method will produce an error.

On 17/08/07, Michael Preslar [EMAIL PROTECTED] wrote:
  

Found something.

For class variables..

http://us.php.net/manual/en/function.property-exists.php

class a {
  var $b;
}

if (property_exists('a','b')) {
  print yes\n;
}


On 8/17/07, Olav Mørkrid [EMAIL PROTECTED] wrote:


the test i need should give the following results:

- FALSE when $a-b does not exist at all
- TRUE when $a-b = null
- TRUE when $a-b = any value

empty() gives true for both $a-b = null and not setting any value, so
that's no good.

borokovs suggestion seems to miss the purpose.

anyone else?

On 17/08/07, Colin Guthrie [EMAIL PROTECTED] wrote:
  

Olav Mørkrid wrote:


how do i test if a property of a stdclass object is set, even if its
value is null, similar to how array_key_exists() works for arrays.

the following method fails:

  $a-b = null;
  if(isset($a-b))
echo yes;

and property_exists() seems only to work for defined objects.

hope someone can help. thanks!
  

You can try:
 unset($a-b)

Or change isset() to empty().

empty() catches more than isset() e.g. '' (empty string), false, 0 etc.
are considered empty. Depending on your logic it can still be very
useful. It is a language construct rather than a function so it's also
efficient.

Col

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




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


  


  


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



[PHP] RE: isset

2007-04-17 Thread Chetanji


Richard Lynch wrote:
 
 On Tue, April 17, 2007 6:59 am, Tim wrote:
 snip
  The count is maintained internally as items are
 added/removed, and it
  is an O(1) operation for PHP to count the array, as it
 already knows
  the answer and just returns it.
 /snip

 Hi nothing to do with the actual topic, i am just wondering how you
 get this
 internals information you all seem to know so much about, it is very
 interesting and i'd like to add it to some of my late night reading
 if
 possible :)
 
 Invent a time machine, go back to the future, and subscribe to this
 list in 1997...
 
 Oh.
 
 Well, another option is to just read a heck of a lot of the archives,
 and the manual, and maybe the Internals list (not for the faint of
 heart) and the books, and maybe peruse some PHP source once in awhile
 and...
 
 There are many paths to enlightenment.
 
 Yes, my son there are many paths to the mountain top.  All are equal in
 that they all have the same ending.
 
 Mostly all of them are long and torturous paths.
 
 If this is your belief then it is so for you.  Most spiritual paths are
 very, very difficult in the first phase or two, 
 thenthings seem to change.
 
 Oh, to keep things within the PHP list, if one checks the SPL- the
 Standard PHP Library, a wealth of information is available as one
 resource.
 
 Blessings,  Chetanji
 
 :-)
 
 -- 
 Some people have a gift link here.
 Know what I want?
 I want you to buy a CD from some indie artist.
 http://cdbaby.com/browse/from/lynch
 Yeah, I get a buck. So?
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 

-- 
View this message in context: 
http://www.nabble.com/isset-tf3578240.html#a10051524
Sent from the PHP - General mailing list archive at Nabble.com.

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



[PHP] Re: isset or array_key_exists?

2006-02-18 Thread Rafael
	After a little test, although the results are not conclusive, I would 
say that isset(), and also that array_key_exists() may even use isset() 
(or similiar) internally as a first step -let's remember that isset() 
only does a fast search and it returns FALSE if the value is NULL; on 
the other hand, array_key_exists() returns TRUE even if the value is 
NULL-  I said this (as an hypotesis) because the difference in time when 
the key exists and when it doesn't is quite big, sometimes about 10 
times slower.


	The script I used to test it was this (it is assumed that any extra 
operation affected both loops equally)

?php

$arr_test = array( 'key' = array( 1 = -1 ) );
$num_oprs = 1000;


$start= micro_time();
for ( $i = 0;  $i  $num_oprs;  $i ++ ) {
if ( isset($arr_test['key'][1]) ) ;
}
echo  'pisset: ', micro_time() - $start, /p\n;


$start = micro_time();
for ( $i = 0;  $i  $num_oprs;  $i ++ ) {
if ( array_key_exists(1, $arr_test['key']) ) ;
}
echo  'parray_key_exists: ', micro_time() - $start, /p\n;



function micro_time( ) {
return  preg_replace('/^0(\.\d+) (\d+)$/X',
 '$2$1', microtime());
}

 ?

Nikolay Rastegaev wrote:

Please, answer:

what construction works faster:

   if (  isset ( $result [$i] [key] )  )
   {do something;   }

or

   if (  array_key_exists ( key, $result [$i] )  )
   {do something;   }

?

--
Atentamente,
J. Rafael Salazar Magaña
Innox - Innovación Inteligente
Tel: +52 (33) 3615 5348 ext. 205 / 01 800 2-SOFTWARE
[EMAIL PROTECTED]
http://www.innox.com.mx

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



Re: [PHP] Re: isset or array_key_exists?

2006-02-18 Thread Robert Cummings
On Sat, 2006-02-18 at 04:56, Rafael wrote:
   After a little test, although the results are not conclusive, I would 
 say that isset(), and also that array_key_exists() may even use isset() 
 (or similiar) internally as a first step -let's remember that isset() 
 only does a fast search and it returns FALSE if the value is NULL; on 
 the other hand, array_key_exists() returns TRUE even if the value is 
 NULL-  I said this (as an hypotesis) because the difference in time when 
 the key exists and when it doesn't is quite big, sometimes about 10 
 times slower.

isset is a keyword in PHP
array_key_exists() is a function.

Keywords are much faster than functions due tot he overhead functions
occur for setting up the stack.

If you don't care about null values, use isset(). If you do, use
array_key_exists().

The reason isset() doesn't return true for null entries has been
described in the past. The official stance was that null is not a value.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] Re: isset or array_key_exists?

2006-02-18 Thread Satyam


- Original Message - 
From: Robert Cummings [EMAIL PROTECTED]

To: Rafael [EMAIL PROTECTED]
Cc: PHP-General php-general@lists.php.net
Sent: Saturday, February 18, 2006 3:21 PM
Subject: Re: [PHP] Re: isset or array_key_exists?



On Sat, 2006-02-18 at 04:56, Rafael wrote:

After a little test, although the results are not conclusive, I would
say that isset(), and also that array_key_exists() may even use isset()
(or similiar) internally as a first step -let's remember that isset()
only does a fast search and it returns FALSE if the value is NULL; on
the other hand, array_key_exists() returns TRUE even if the value is
NULL-  I said this (as an hypotesis) because the difference in time when
the key exists and when it doesn't is quite big, sometimes about 10
times slower.


isset is a keyword in PHP
array_key_exists() is a function.

Keywords are much faster than functions due tot he overhead functions
occur for setting up the stack.

If you don't care about null values, use isset(). If you do, use
array_key_exists().

The reason isset() doesn't return true for null entries has been
described in the past. The official stance was that null is not a value.

Cheers,
Rob.
--



Accessing a non-existing element, doesn't create it? Thus, using isset to 
evaluate whether an element exists creates it, though with a null value.  If 
you make a first pass on the array with isset, a second pass with 
array_key_exists would give true for all of them though isset would give the 
same results as in the first pass.  I think this happened to me once when I 
went through an array with isset or isempty or some such to make some 
calculations and then on the second pass, when I printed it, I got lots of 
empty cells that were created empty in the first pass.


Satyam

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



Re: [PHP] Re: isset or array_key_exists?

2006-02-18 Thread Rafael
	Actually, it doesn't have much sense that it creates a variable (or 
index), though it had sense why wouldn't be so easily detected, so I 
printed the array after the loops and there's no new keys.  I think that 
if that was the case, it was definitely a bug that has been corrected 
(PHP 4.4.0)

*Note: I guess that's because isset() is not a function, but a keyword

	That was very ilustrative Rob, thanks for the info (it's the kind of 
thing I shouldn't forget)


Satyam wrote:
[···]

isset is a keyword in PHP
array_key_exists() is a function.

Keywords are much faster than functions due tot he overhead functions
occur for setting up the stack.

If you don't care about null values, use isset(). If you do, use
array_key_exists().

The reason isset() doesn't return true for null entries has been
described in the past. The official stance was that null is not a value.


[···]


Accessing a non-existing element, doesn't create it? Thus, using isset 
to evaluate whether an element exists creates it, though with a null 
value.  If you make a first pass on the array with isset, a second pass 
with array_key_exists would give true for all of them though isset would 
give the same results as in the first pass.  I think this happened to me 
once when I went through an array with isset or isempty or some such to 
make some calculations and then on the second pass, when I printed it, I 
got lots of empty cells that were created empty in the first pass.

--
Atentamente,
J. Rafael Salazar Magaña
Innox - Innovación Inteligente
Tel: +52 (33) 3615 5348 ext. 205 / 01 800 2-SOFTWARE
[EMAIL PROTECTED]
http://www.innox.com.mx

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



Re: [PHP] Re: isset or array_key_exists?

2006-02-18 Thread Robert Cummings

On Sat, 2006-02-18 at 12:39, Rafael wrote:
   Actually, it doesn't have much sense that it creates a variable (or 
 index), though it had sense why wouldn't be so easily detected, so I 
 printed the array after the loops and there's no new keys.  I think that 
 if that was the case, it was definitely a bug that has been corrected 
 (PHP 4.4.0)
 *Note: I guess that's because isset() is not a function, but a keyword
 
   That was very ilustrative Rob, thanks for the info (it's the kind of 
 thing I shouldn't forget)
 
 Satyam wrote:
 [···]
  isset is a keyword in PHP
  array_key_exists() is a function.
 
  Keywords are much faster than functions due tot he overhead functions
  occur for setting up the stack.
 
  If you don't care about null values, use isset(). If you do, use
  array_key_exists().
 
  The reason isset() doesn't return true for null entries has been
  described in the past. The official stance was that null is not a value.
 
 [···]
  
  Accessing a non-existing element, doesn't create it? Thus, using isset 
  to evaluate whether an element exists creates it, though with a null 
  value.  If you make a first pass on the array with isset, a second pass 
  with array_key_exists would give true for all of them though isset would 
  give the same results as in the first pass.  I think this happened to me 
  once when I went through an array with isset or isempty or some such to 
  make some calculations and then on the second pass, when I printed it, I 
  got lots of empty cells that were created empty in the first pass.

For the curious:

?php

function myempty( $value )
{
if( empty( $value ) )
{
return true;
}

return false;
}

$foo = array( 1 = 1 );

if( isset( $foo[2] ) )
{
echo 'WTF! :)';
}

print_r( $foo );

if( !empty( $foo[2] ) )
{
echo 'WTF! :)';
}

print_r( $foo );

if( !myempty( $foo[2] ) )
{
echo 'WTF! :)';
}

print_r( $foo );

?

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] Re: isset

2005-02-16 Thread M. Sokolewicz
Marek Kilimajer wrote:
M. Sokolewicz wrote:
Also note that empty($non_existent_var) will always throw an E_NOTICE 
error when the variable in question is not set.

No, it does not.
hmm... seems to have changed since I last checked (PHP5 change?)
I appoligize :)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: isset

2005-02-16 Thread Matthew Weier O'Phinney
* Bret Hughes [EMAIL PROTECTED]:
 I just wish there was a use strict; sort of deal so I would not have to
 hunt down logic errors due to mistyping a variable name.

There is, in PHP5: E_STRICT. From the manual
(http://php.net/manual/en/ref.errorfunc.php#errorfunc.constants):

Run-time notices. Enable to have PHP suggest changes to your 
code which will ensure the best interoperability and forward
compatibility of your code. 

-- 
Matthew Weier O'Phinney   | WEBSITES:
Webmaster and IT Specialist   | http://www.garden.org
National Gardening Association| http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org
mailto:[EMAIL PROTECTED] | http://vermontbotanical.org

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



Re: [PHP] Re: isset

2005-02-16 Thread Bret Hughes
On Wed, 2005-02-16 at 07:54, Matthew Weier O'Phinney wrote:
 * Bret Hughes [EMAIL PROTECTED]:
  I just wish there was a use strict; sort of deal so I would not have to
  hunt down logic errors due to mistyping a variable name.
 
 There is, in PHP5: E_STRICT. From the manual
 (http://php.net/manual/en/ref.errorfunc.php#errorfunc.constants):
 
 Run-time notices. Enable to have PHP suggest changes to your 
 code which will ensure the best interoperability and forward
 compatibility of your code. 
 

Hmm.  Good tip thanks.  chalk up another reason to upgrade to 5. 
getting close to haveing enough reasons to do so :)

E_STRICT is closer but still does not warn of assigning to undeclared
variables in or out of a class. bummer.

Bret

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



Re: [PHP] Re: isset

2005-02-16 Thread Richard Lynch
Bret Hughes wrote:
 On Wed, 2005-02-16 at 07:54, Matthew Weier O'Phinney wrote:
 * Bret Hughes [EMAIL PROTECTED]:
  I just wish there was a use strict; sort of deal so I would not have
 to
  hunt down logic errors due to mistyping a variable name.

 There is, in PHP5: E_STRICT. From the manual
 (http://php.net/manual/en/ref.errorfunc.php#errorfunc.constants):

 Run-time notices. Enable to have PHP suggest changes to your
 code which will ensure the best interoperability and forward
 compatibility of your code.


 Hmm.  Good tip thanks.  chalk up another reason to upgrade to 5.
 getting close to haveing enough reasons to do so :)

 E_STRICT is closer but still does not warn of assigning to undeclared
 variables in or out of a class. bummer.

Assigning to an undeclared variable out of a class has no meaning in PHP,
because there are no declarations of variables outside of a class.

Declarations of variables inside of a class are pretty much for
documentation or initialization to a constant, but to be consistent with
the general theme of PHP assignment and PHP as a loosely-typed language,
it's perfectly legal syntactically and logically to assign to a new
property on a class.

So you're probably never gonna see a warning for assigning to an
undeclared variable, even in the class system...  It would have to be,
like, E_SO_STRICT_YOU_SHOULD_BE_USING_C_ANYWAY :-)

You SHOULD be using E_NOTICE to get warned when you *USE* an unassigned
variable/propery/element and PHP is forced to initialize it.

That will catch a bunch of your variable name typos -- And also will often
let you know you typed it wrong in the place where you did the assignment.
EG:

?php
  $mispeled = 'test'; //line 2
  echo $mispelled; //line 3
?

The typo is in the assignment, but you'll get warned in line 3.  Composing
a more convoluted example involving a class and 100 lines of code is left
as an exercise for the reader.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Re: isset

2005-02-16 Thread Bret Hughes
On Wed, 2005-02-16 at 10:34, Richard Lynch wrote:
 Bret Hughes wrote:
  On Wed, 2005-02-16 at 07:54, Matthew Weier O'Phinney wrote:
  * Bret Hughes [EMAIL PROTECTED]:
   I just wish there was a use strict; sort of deal so I would not have
  to
   hunt down logic errors due to mistyping a variable name.

 You SHOULD be using E_NOTICE to get warned when you *USE* an unassigned
 variable/propery/element and PHP is forced to initialize it.
 
 That will catch a bunch of your variable name typos -- And also will often
 let you know you typed it wrong in the place where you did the assignment.
 EG:


this is exactly what I was looking for Richard thanks.

Bret

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



Re: [PHP] Re: isset

2005-02-16 Thread Bauglir
It's common mistake what you are doing...
the first thing should be to test if there is such key in array:
if (array_key_exists('cmd',$_POST))
{
}
this means to test it the variable exists, then you can test if it was set
Brona
Chris W. Parker wrote:
M. Sokolewicz mailto:[EMAIL PROTECTED]
on Tuesday, February 15, 2005 8:25 AM said:

seems lengthy. is there a way around this?
i tried using
$cmd = @ $_POST['cmd'];
to suppress errors but didnt seem to have ay effect.
still
if(isset($_POST['cmd'])) {
   $cmd = $_POST['cmd'];
}
is the only (really) correct way. All others throw notices of
undefined indices, which you *should not* ignore! You can't shorten
it, you can't even wrap it in a function... it's simply tough luck

Please correct me if I'm wrong (and maybe this is what you mean by
(really)) but I think even Rasmus recommends:
?php
  if(!empty($_POST['cmd']))
  {
// stuff
  }
?
I'm using the following code to test this:
?php
error_reporting(E_ALL);
if(!empty($_POST['cmd']))
{
echo set and not emptybr /;
}
else
{
echo empty and/or not setbr /;
}
?

Chris.

--
s pozdravem
  Bronislav Klucka
--=[ pro2-soft.com ]=--
http://pro2-soft.com
[EMAIL PROTECTED]
+420 605 58 29 22
   * webove aplikace
   * software na zakazku
---
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: isset

2005-02-15 Thread M. Sokolewicz
D_c wrote:
I often use this type of construct 

$cmd = $_POST['cmd'];
if ($cmd == null) { // do default
but this throws a notice if the ['cmd'] index is not defined. ugly.
using 

if (isset($_POST['cmd'] ) {
  $cmd = $_POST['cmd'];
} 

seems lengthy. is there a way around this?
i tried using 
$cmd = @ $_POST['cmd'];

to suppress errors but didnt seem to have ay effect. 

tx.

still
if(isset($_POST['cmd'])) {
   $cmd = $_POST['cmd'];
}
is the only (really) correct way. All others throw notices of undefined 
indices, which you *should not* ignore! You can't shorten it, you can't 
even wrap it in a function... it's simply tough luck

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


RE: [PHP] Re: isset

2005-02-15 Thread Chris W. Parker
M. Sokolewicz mailto:[EMAIL PROTECTED]
on Tuesday, February 15, 2005 8:25 AM said:

 seems lengthy. is there a way around this?
 
 i tried using
 $cmd = @ $_POST['cmd'];
 
 to suppress errors but didnt seem to have ay effect.
 
 still
 if(isset($_POST['cmd'])) {
 $cmd = $_POST['cmd'];
 }
 
 is the only (really) correct way. All others throw notices of
 undefined indices, which you *should not* ignore! You can't shorten
 it, you can't even wrap it in a function... it's simply tough luck

Please correct me if I'm wrong (and maybe this is what you mean by
(really)) but I think even Rasmus recommends:

?php

  if(!empty($_POST['cmd']))
  {
// stuff
  }

?

I'm using the following code to test this:

?php

error_reporting(E_ALL);

if(!empty($_POST['cmd']))
{
echo set and not emptybr /;
}
else
{
echo empty and/or not setbr /;
}

?




Chris.

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



Re: [PHP] Re: isset

2005-02-15 Thread M. Sokolewicz
Chris W. Parker wrote:
M. Sokolewicz mailto:[EMAIL PROTECTED]
on Tuesday, February 15, 2005 8:25 AM said:

seems lengthy. is there a way around this?
i tried using
$cmd = @ $_POST['cmd'];
to suppress errors but didnt seem to have ay effect.
still
if(isset($_POST['cmd'])) {
   $cmd = $_POST['cmd'];
}
is the only (really) correct way. All others throw notices of
undefined indices, which you *should not* ignore! You can't shorten
it, you can't even wrap it in a function... it's simply tough luck

Please correct me if I'm wrong (and maybe this is what you mean by
(really)) but I think even Rasmus recommends:
?php
  if(!empty($_POST['cmd']))
  {
// stuff
  }
?
I'm using the following code to test this:
?php
error_reporting(E_ALL);
if(!empty($_POST['cmd']))
{
echo set and not emptybr /;
}
else
{
echo empty and/or not setbr /;
}
?

Chris.
that's a different issue.
There are always at least 2 things you should do with your (expected) input:
1 - check if it *exists* (isset)
2 - check the validity (input-validation)
for step #2 empty is very commonly used, and also a very useful 
function. However, you should never do #2 without #1, since that again 
raises issues (of security, problems, unexpected input, etc)

Also note that empty($non_existent_var) will always throw an E_NOTICE 
error when the variable in question is not set. isset() is the only 
function/language-construct that can check for the existence of 
variables without throwing an E_NOTICE.

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


Re: [PHP] Re: isset

2005-02-15 Thread Marek Kilimajer
M. Sokolewicz wrote:
Also note that empty($non_existent_var) will always throw an E_NOTICE 
error when the variable in question is not set.
No, it does not.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: isset

2005-02-15 Thread Bret Hughes
On Tue, 2005-02-15 at 16:22, M. Sokolewicz wrote:

  Chris.
 that's a different issue.
 There are always at least 2 things you should do with your (expected) input:
 1 - check if it *exists* (isset)
 2 - check the validity (input-validation)
 
 for step #2 empty is very commonly used, and also a very useful 
 function. However, you should never do #2 without #1, since that again 
 raises issues (of security, problems, unexpected input, etc)
 
 Also note that empty($non_existent_var) will always throw an E_NOTICE 
 error when the variable in question is not set. isset() is the only 
 function/language-construct that can check for the existence of 
 variables without throwing an E_NOTICE.


This is not true and explicitly states so in the doc.  I had to reread
it to remember why I stopped using it.  empty will return true if the
value is one of several things , 0, 0 to name a few.  Since I do not
consider these empty I stick with isset and then test for a valid value
depending on the circumstance.

Personally, I think people piss and moan too much about what I consider
proper coding practices.  Input validation is to important to skimp on.
Again it is my opinion.

I have been revisiting some php code that I wrote a couple of years ago
and have been pleasantly surprised at the job I did on input validation.

A similar complaint occurs when installing a new version of or moving
code to another box where register_globals is not on.  I pissed and
moaned and wailed for about 10 minutes until I thought about it and can
now see the value in not having unknown variables pollute the namespace.

Of course, since most of my code was already validating the variables, a
few :s/\$\(var\)/\$_GET[\1]/ iterations and I was good to go.  Yes it
took some time but I feel better having done it.

I just wish there was a use strict; sort of deal so I would not have to
hunt down logic errors due to mistyping a variable name.

Bret

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



[PHP] Re: IsSet() and $_SESSION

2003-06-30 Thread John Manko
None of these worked for me.  ok, if you look at the code, the part 
where echo $_SESSION['uid']; is actually works.
I get a print out of the variable.  if i call session_start() before 
anything, set variables in $_SESSION, and check it on another page, the 
session variables do not exist.  in fact, the session isnt even started, 
cause I get an Undefined variable _SESSION.  so, it looks like the 
session is not spamming page requests.  Do I have to call 
session_start() on every page to read the $_SESSION variables set in 
another?

Shivanischal A wrote:

John,

I can think of 3 problems...
1. I'm not sure, but try inserting a 'session_start()' in file.php
2. in ur validateadminlogin() method, the mysql_close() never seems to get
called.
3. try $_SESSION['uid'] . use ' instead of .  seema to cause problems in
some cases.
best of luck,
-shiva
- Original Message -
From: John Manko [EMAIL PROTECTED]
Newsgroups: php.general
To: [EMAIL PROTECTED]
Sent: Monday, June 30, 2003 6:49 AM
Subject: IsSet() and $_SESSION
 

I'm having a problem with the value that isset returns on $_SESSION
variables.  For some reason, even if $_SESSION['uid'] is set, isset
returns FALSE.  Here is the code:
-- file1.php ---
include file2.php;
if (!isset($_SESSION[uid])) {
// This first time $_SESSION[uid] is check, we should
// end up in here.  However, ValidAdminLogin (next test)
// will set $_SESSION[uid] so next time we will not
// get here.
if ( !ValidAdminLogin($_POST[adminid],$_POST[adminpass]))
forceadminlogin();
} elseif ( !ValidAdminSession() )
forceadminlogin();
// this is done to show that $_SESSION[uid] is being set
// but isset still returns false
echo $_SESSION[uid];
-- file2.php ---
function ValidAdminLogin($user, $pass){
global $_SESSION;

if (The_MYSQL_Stuff_Is_NOT_OK) return false;
else
{
 session_start();
 $_SESSION[logged] = true;
 $_SESSION[username] = $user;
 $_SESSION[adminlogin] = true;
 $_SESSION[fname] = $fname;
 $_SESSION[lname] = $lname;
 $_SESSION[email] = $email;
 $_SESSION[uid] = session_id();
  return true;
}
mysql_close();

}



   



DISCLAIMER: This email is bound by the terms and conditions described at 
http://www.subexgroup.com/mail-disclaimer.htm



 



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


RE: [PHP] Re: IsSet() and $_SESSION

2003-06-30 Thread Ford, Mike [LSS]
 -Original Message-
 From: John Manko [mailto:[EMAIL PROTECTED]
 Sent: 30 June 2003 15:14
 To: [EMAIL PROTECTED]
 Subject: [PHP] Re: IsSet() and $_SESSION
 
 
 None of these worked for me.  ok, if you look at the code, the part 
 where echo $_SESSION['uid']; is actually works.
 I get a print out of the variable.  if i call session_start() before 
 anything, set variables in $_SESSION, and check it on another 
 page, the 
 session variables do not exist.  in fact, the session isnt 
 even started, 
 cause I get an Undefined variable _SESSION.  so, it looks like the 
 session is not spamming page requests.  Do I have to call 
 session_start() on every page to read the $_SESSION variables set in 
 another?

Yes.  Every page that needs access to the session variables must call session_start(). 
 That's what it means on http://www.php.net/session-start when it says creates a 
session or resumes the current one.

In practice, this means every page, as even if you don't access any session variables 
you may still need the session ID in order to pass it along to the next page (even if 
only implicitly via session.use_trans_sid).

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



[PHP] Re: isset

2002-07-09 Thread vins

It's kinda like microsoft
nothing really works unless you have Internet Explorer and the internet
LOL



Preston Wade [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hello All,

 I am trying to use the isset function to test if the page has been
 submitted, but it seems as though it is not working.  I am wondering is
 there a configuration option that is messing with the functionality of
 isset.

 Any help would be appreciated.

 Thanks,
 Preston Wade




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




[PHP] Re: isset

2002-07-09 Thread vins

i think what you're trying to do is

?php
if($REQUEST_METHOD == POST)
{
echo Form has been submitted.;
exit;
}
else
{
echo Display the form that has to be submitted.':
exit;
}
?


Preston Wade [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hello All,

 I am trying to use the isset function to test if the page has been
 submitted, but it seems as though it is not working.  I am wondering is
 there a configuration option that is messing with the functionality of
 isset.

 Any help would be appreciated.

 Thanks,
 Preston Wade




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




RE: [PHP] Re: isset

2002-07-09 Thread Preston Wade

Actually here is what I am trying to do.

?php
if (isset($submit)) {
   echo Submitted!;
}
?
 
form action=?=$PHP_SELF ?  method=post
blah, blah
input type=submit name=submit value=Submit
/form


 -Original Message-
 From: vins [EMAIL PROTECTED]@INTERNET@HHC 
 Sent: Tuesday, July 09, 2002 5:35 PM
 To:   [EMAIL PROTECTED]
 Subject:  [PHP] Re: isset
 
 i think what you're trying to do is
 
 ?php
 if($REQUEST_METHOD == POST)
 {
 echo Form has been submitted.;
 exit;
 }
 else
 {
 echo Display the form that has to be submitted.':
 exit;
 }
 ?
 
 
 Preston Wade [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  Hello All,
 
  I am trying to use the isset function to test if the page has been
  submitted, but it seems as though it is not working.  I am wondering is
  there a configuration option that is messing with the functionality of
  isset.
 
  Any help would be appreciated.
 
  Thanks,
  Preston Wade
 
 
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 


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




Re: [PHP] Re: isset

2002-07-09 Thread vins

oh ok.
that is easy to forge then

try the script that i wrong earliers... it's must safer.



Preston Wade [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Actually here is what I am trying to do.

 ?php
 if (isset($submit)) {
echo Submitted!;
 }
 ?

 form action=?=$PHP_SELF ?  method=post
 blah, blah
 input type=submit name=submit value=Submit
 /form


  -Original Message-
  From: vins [EMAIL PROTECTED]@INTERNET@HHC
  Sent: Tuesday, July 09, 2002 5:35 PM
  To: [EMAIL PROTECTED]
  Subject: [PHP] Re: isset
 
  i think what you're trying to do is
 
  ?php
  if($REQUEST_METHOD == POST)
  {
  echo Form has been submitted.;
  exit;
  }
  else
  {
  echo Display the form that has to be submitted.':
  exit;
  }
  ?
 
 
  Preston Wade [EMAIL PROTECTED] wrote in message
  [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
   Hello All,
  
   I am trying to use the isset function to test if the page has been
   submitted, but it seems as though it is not working.  I am wondering
is
   there a configuration option that is messing with the functionality of
   isset.
  
   Any help would be appreciated.
  
   Thanks,
   Preston Wade
  
 
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 




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




[PHP] Re: !isset ??

2002-02-08 Thread LaserJetter

If you try and use $var in an operation ( i.e.  .=   == etc) and you
get an error saying Undefined variable then isset($var) = FALSE


LJ


Erik Price [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hm.  I hope I'm not opening an old wound:

 Curious about the proper way to test for the existence of a variable, I
 decided to read up on isset() at php.net's function manual pages.  It
 seems at first to be a way to test whether or not a variable has been
 set.

 But reading the annotations below the documentation is mind boggling.
 Back and forth, it seems to go -- and then to find out that one method
 is to be used to test for POSTed variables, and another to be used for
 GETted variables (for $_POST, use $_POST['var'] !='' , and for $_GET,
 use !isset($_GET['var'])).

 Pretty confusing.  Can anyone shed some light on whether or not there is
 a final definite way to do this?  I've used (!($_POST['var'])) with no
 problems in the past, but does good coding style suggest that I use
 (!isset($_POST['var'])) now?


 Erik





 

 Erik Price
 Web Developer Temp
 Media Lab, H.H. Brown
 [EMAIL PROTECTED]




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




[PHP] Re: !isset ??

2002-02-06 Thread Julio Nobrega Trabalhando

  If your purpose is to see if an user wrote or selected anything, you can
do:

if (ereg(^[[:blank:]]*$,$_POST['var'])) {
// It has only spaces
}

  I am sorry if does not fit your need like I interpreted. But, just for not
getting flamed, !isset() works fine for me on both cases (so far where I
tested);

--

Julio Nobrega.

Um dia eu chego lá:
http://sourceforge.net/projects/toca

Ajudei? Salvei? Que tal um presentinho?
http://www.submarino.com.br/wishlistclient.asp?wlid=664176742884


Erik Price [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hm.  I hope I'm not opening an old wound:

 Curious about the proper way to test for the existence of a variable, I
 decided to read up on isset() at php.net's function manual pages.  It
 seems at first to be a way to test whether or not a variable has been
 set.

 But reading the annotations below the documentation is mind boggling.
 Back and forth, it seems to go -- and then to find out that one method
 is to be used to test for POSTed variables, and another to be used for
 GETted variables (for $_POST, use $_POST['var'] !='' , and for $_GET,
 use !isset($_GET['var'])).

 Pretty confusing.  Can anyone shed some light on whether or not there is
 a final definite way to do this?  I've used (!($_POST['var'])) with no
 problems in the past, but does good coding style suggest that I use
 (!isset($_POST['var'])) now?


 Erik





 

 Erik Price
 Web Developer Temp
 Media Lab, H.H. Brown
 [EMAIL PROTECTED]




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




[PHP] Re: !isset ??

2002-02-06 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Erik Price) wrote:

 Pretty confusing.  Can anyone shed some light on whether or not there is 
 a final definite way to do this?  I've used (!($_POST['var'])) with no 
 problems in the past, but does good coding style suggest that I use 
 (!isset($_POST['var'])) now?

!$somevar != !isset($somevar)

isset() evaluates as true only if the variable (or array index) exists.

PHP's loose typing means that !$somevar evalutes as true if the variable is 
null, if it has an (integer, float, or string) value of zero, if it's an 
empty string, or if it is set to boolean false. Or if the variable/index 
does not exist.

Both methods have their place (though for tests of the latter, I prefer 
empty()).  The important part is understanding the implications of a method 
when you use it, so that your code isn't wrongly relying on !$somevar to 
mean the variable isn't set; it may well have been set, to a meaningful 
value which just happens to evaluate to false.

-- 
CC

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




Re: [PHP] Re: !isset ??

2002-02-06 Thread Erik Price


On Wednesday, February 6, 2002, at 03:28  PM, CC Zona wrote:

 PHP's loose typing means that !$somevar evalutes as true if the 
 variable is
 null, if it has an (integer, float, or string) value of zero, if it's an
 empty string, or if it is set to boolean false. Or if the variable/index
 does not exist.

 Both methods have their place (though for tests of the latter, I prefer
 empty()).  The important part is understanding the implications of a 
 method
 when you use it, so that your code isn't wrongly relying on !$somevar to
 mean the variable isn't set; it may well have been set, to a meaningful
 value which just happens to evaluate to false.



I guess the best thing to do is to test it each way when I'm testing for 
variables and make sure that the method I end up going with works 
correctly for true and false values, whatever they may end up 
being.  No BFD, I was just wondering if there was a definite method for 
doing these tests.

Thanks to all who've responded on this thread.


Erik





Erik Price
Web Developer Temp
Media Lab, H.H. Brown
[EMAIL PROTECTED]


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




[PHP] Re: isset

2001-09-05 Thread Richard Lynch

 Is there anyway of hiding the name of the website in the isset Enter
 Network Password window?

 if (isset( $PHP_AUTH_USER )  isset($PHP_AUTH_PW))

No.  The browser puts it there, and PHP has no control over it.

And, if you could, it would be in the Location: bar anyway.

Actually...  *MAYBE* you could mess around with settings in httpd.conf that
would affect that, but it would also affect their surfing and the Location:
bar of the browser as well.

You *COULD* incorporate something into the Realm so that you are at least
presenting another URL to the user along with the real one.

--
WARNING [EMAIL PROTECTED] address is an endangered species -- Use
[EMAIL PROTECTED]
Wanna help me out?  Like Music?  Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: isset and multiple selects

2001-03-11 Thread Alexander Lohse

Hi,

No, empty(), also does not apply, because it is not set.

It is NOT in the HTTO_POST_VARS Array!

Is this a usual behavior?

Greets,

Alex
-- 
___
Alexander Lohse
Human Touch Medienproduktion GmbH
Am See 1
17440 Klein Jasedow

Tel: (038374) 75211
Fax: (038374) 75223
eMail: [EMAIL PROTECTED]
http://www.humantouch.de

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]