Re: [PHP] Re: isset question
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
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
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
Re: [PHP] Re: isset($a-b) even if $a-b = null
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
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
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
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
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
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. -- .. | 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?
- 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?
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?
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
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
* 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
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
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
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
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
RE: [PHP] Re: isset
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
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
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
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
RE: [PHP] Re: IsSet() and $_SESSION
-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
RE: [PHP] Re: isset
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
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
Re: [PHP] if(isset($submit))
jtjohnston wrote: I can't get this to work: if(isset($submit)) with: input type=\image\ name=\submit\ value=\submit\ src=\nextgif\ border=\0\ align=\ABSCENTER\ I'm not coding correctly? If you are testing for $submit a work around is to have a hidden field in your form that looks like this: input type=hidden name=submit value=yes That way any tests for $submit will come up as true once the form has been submitted, but you can still use an image for the actual button -- PHP General Mailing List (http://wwwphpnet/) To unsubscribe, visit: http://wwwphpnet/unsubphp
Re: [PHP] if(isset($submit))
just use an input type=hidden and call it submit,thats what i do - Original Message - From: jtjohnston [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, February 28, 2002 5:32 AM Subject: Re: [PHP] if(isset($submit)) So I can forget using type=image :( Wah, it's not fair! :) J Martin Towell wrote: I used this code form action=/inetpub/wwwroot/top.html method=get input type=image src=none.gif width=125 height=25 name=submit value=submit /form when I clicked on the image, I got this url file:///C:/inetpub/wwwroot/top.html?submit.x=118submit.y=20 so php would get this as $submit_x and $submit_y HTH Martin -Original Message- From: jtjohnston [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 28, 2002 4:17 PM To: [EMAIL PROTECTED] Subject: [PHP] if(isset($submit)) Has anyone tried: input type=\image\ name=\submit\ value=\submit\ src=\next.gif\ border=\0\ align=\ABSCENTER\ instead of : input type=\submit\ name=\submit\ value=\\ I can't get this to work: if(isset($submit)) with: input type=\image\ name=\submit\ value=\submit\ src=\next.gif\ border=\0\ align=\ABSCENTER\ I'm not coding correctly? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- John Taylor-Johnston -- --- ' ' ' Collège de Sherbrooke: ô¿ô http://www.collegesherbrooke.qc.ca/languesmodernes/ - Université de Sherbrooke: http://compcanlit.ca/ 819-569-2064 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] if(isset($submit))
I used this code form action=/inetpub/wwwroot/top.html method=get input type=image src=none.gif width=125 height=25 name=submit value=submit /form when I clicked on the image, I got this url file:///C:/inetpub/wwwroot/top.html?submit.x=118submit.y=20 so php would get this as $submit_x and $submit_y HTH Martin -Original Message- From: jtjohnston [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 28, 2002 4:17 PM To: [EMAIL PROTECTED] Subject: [PHP] if(isset($submit)) Has anyone tried: input type=\image\ name=\submit\ value=\submit\ src=\next.gif\ border=\0\ align=\ABSCENTER\ instead of : input type=\submit\ name=\submit\ value=\\ I can't get this to work: if(isset($submit)) with: input type=\image\ name=\submit\ value=\submit\ src=\next.gif\ border=\0\ align=\ABSCENTER\ I'm not coding correctly? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] if(isset($submit))
I s'pose, but where/why are you getting submit.x=118submit.y=20 Martin Towell wrote: I used this code form action=/inetpub/wwwroot/top.html method=get input type=image src=none.gif width=125 height=25 name=submit value=submit /form when I clicked on the image, I got this url file:///C:/inetpub/wwwroot/top.html?submit.x=118submit.y=20 so php would get this as $submit_x and $submit_y HTH Martin -Original Message- From: jtjohnston [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 28, 2002 4:17 PM To: [EMAIL PROTECTED] Subject: [PHP] if(isset($submit)) Has anyone tried: input type=\image\ name=\submit\ value=\submit\ src=\next.gif\ border=\0\ align=\ABSCENTER\ instead of : input type=\submit\ name=\submit\ value=\\ I can't get this to work: if(isset($submit)) with: input type=\image\ name=\submit\ value=\submit\ src=\next.gif\ border=\0\ align=\ABSCENTER\ I'm not coding correctly? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- John Taylor-Johnston - ' ' ' Collège de Sherbrooke: ô¿ô http://www.collegesherbrooke.qc.ca/languesmodernes/ - Université de Sherbrooke: http://compcanlit.ca/ 819-569-2064
RE: [PHP] if(isset($submit))
it's a browser thing, i guess, when you use an image as a submit button Martin -Original Message- From: jtjohnston [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 28, 2002 4:28 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] if(isset($submit)) I s'pose, but where/why are you getting submit.x=118submit.y=20 Martin Towell wrote: I used this code form action=/inetpub/wwwroot/top.html method=get input type=image src=none.gif width=125 height=25 name=submit value=submit /form when I clicked on the image, I got this url file:///C:/inetpub/wwwroot/top.html?submit.x=118submit.y=20 so php would get this as $submit_x and $submit_y HTH Martin -Original Message- From: jtjohnston [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 28, 2002 4:17 PM To: [EMAIL PROTECTED] Subject: [PHP] if(isset($submit)) Has anyone tried: input type=\image\ name=\submit\ value=\submit\ src=\next.gif\ border=\0\ align=\ABSCENTER\ instead of : input type=\submit\ name=\submit\ value=\\ I can't get this to work: if(isset($submit)) with: input type=\image\ name=\submit\ value=\submit\ src=\next.gif\ border=\0\ align=\ABSCENTER\ I'm not coding correctly? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- John Taylor-Johnston - ' ' ' Collège de Sherbrooke: ô¿ô http://www.collegesherbrooke.qc.ca/languesmodernes/ - Université de Sherbrooke: http://compcanlit.ca/ 819-569-2064
Re: [PHP] if(isset($submit))
It's because when you submit using an image they submit the exact x and y coordinates that were clicked on. Hope it helps! Rick We do not have to visit a mad house to find disordered minds; our planet is the mental institution of the universe. - Unknown From: jtjohnston [EMAIL PROTECTED] Organization: FLSH, Université de Sherbrooke Reply-To: [EMAIL PROTECTED] Date: Thu, 28 Feb 2002 00:28:09 -0500 To: [EMAIL PROTECTED] Subject: Re: [PHP] if(isset($submit)) I s'pose, but where/why are you getting submit.x=118submit.y=20 Martin Towell wrote: I used this code form action=/inetpub/wwwroot/top.html method=get input type=image src=none.gif width=125 height=25 name=submit value=submit /form when I clicked on the image, I got this url file:///C:/inetpub/wwwroot/top.html?submit.x=118submit.y=20 so php would get this as $submit_x and $submit_y HTH Martin -Original Message- From: jtjohnston [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 28, 2002 4:17 PM To: [EMAIL PROTECTED] Subject: [PHP] if(isset($submit)) Has anyone tried: input type=\image\ name=\submit\ value=\submit\ src=\next.gif\ border=\0\ align=\ABSCENTER\ instead of : input type=\submit\ name=\submit\ value=\\ I can't get this to work: if(isset($submit)) with: input type=\image\ name=\submit\ value=\submit\ src=\next.gif\ border=\0\ align=\ABSCENTER\ I'm not coding correctly? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- John Taylor-Johnston - ' ' ' Collège de Sherbrooke: ô¿ô http://www.collegesherbrooke.qc.ca/languesmodernes/ - Université de Sherbrooke: http://compcanlit.ca/ 819-569-2064 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] if(isset($submit))
Nope, not following. :) More particularily why will isset accept type=submit and not type=image ? Martin Towell wrote: I used this code form action=/inetpub/wwwroot/top.html method=get input type=image src=none.gif width=125 height=25 name=submit value=submit /form when I clicked on the image, I got this url file:///C:/inetpub/wwwroot/top.html?submit.x=118submit.y=20 so php would get this as $submit_x and $submit_y HTH Martin -Original Message- From: jtjohnston [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 28, 2002 4:17 PM To: [EMAIL PROTECTED] Subject: [PHP] if(isset($submit)) Has anyone tried: input type=\image\ name=\submit\ value=\submit\ src=\next.gif\ border=\0\ align=\ABSCENTER\ instead of : input type=\submit\ name=\submit\ value=\\ I can't get this to work: if(isset($submit)) with: input type=\image\ name=\submit\ value=\submit\ src=\next.gif\ border=\0\ align=\ABSCENTER\ I'm not coding correctly? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- John Taylor-Johnston - ' ' ' Collège de Sherbrooke: ô¿ô http://www.collegesherbrooke.qc.ca/languesmodernes/ - Université de Sherbrooke: http://compcanlit.ca/ 819-569-2064
Re: [PHP] if(isset($submit))
So I can forget using type=image :( Wah, it's not fair! :) J Martin Towell wrote: I used this code form action=/inetpub/wwwroot/top.html method=get input type=image src=none.gif width=125 height=25 name=submit value=submit /form when I clicked on the image, I got this url file:///C:/inetpub/wwwroot/top.html?submit.x=118submit.y=20 so php would get this as $submit_x and $submit_y HTH Martin -Original Message- From: jtjohnston [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 28, 2002 4:17 PM To: [EMAIL PROTECTED] Subject: [PHP] if(isset($submit)) Has anyone tried: input type=\image\ name=\submit\ value=\submit\ src=\next.gif\ border=\0\ align=\ABSCENTER\ instead of : input type=\submit\ name=\submit\ value=\\ I can't get this to work: if(isset($submit)) with: input type=\image\ name=\submit\ value=\submit\ src=\next.gif\ border=\0\ align=\ABSCENTER\ I'm not coding correctly? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- John Taylor-Johnston - ' ' ' Collège de Sherbrooke: ô¿ô http://www.collegesherbrooke.qc.ca/languesmodernes/ - Université de Sherbrooke: http://compcanlit.ca/ 819-569-2064
RE: [PHP] if(isset($submit))
or have a hidden field, maybe, called submit -Original Message- From: jtjohnston [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 28, 2002 4:33 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] if(isset($submit)) So I can forget using type=image :( Wah, it's not fair! :) J Martin Towell wrote: I used this code form action=/inetpub/wwwroot/top.html method=get input type=image src=none.gif width=125 height=25 name=submit value=submit /form when I clicked on the image, I got this url file:///C:/inetpub/wwwroot/top.html?submit.x=118submit.y=20 so php would get this as $submit_x and $submit_y HTH Martin -Original Message- From: jtjohnston [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 28, 2002 4:17 PM To: [EMAIL PROTECTED] Subject: [PHP] if(isset($submit)) Has anyone tried: input type=\image\ name=\submit\ value=\submit\ src=\next.gif\ border=\0\ align=\ABSCENTER\ instead of : input type=\submit\ name=\submit\ value=\\ I can't get this to work: if(isset($submit)) with: input type=\image\ name=\submit\ value=\submit\ src=\next.gif\ border=\0\ align=\ABSCENTER\ I'm not coding correctly? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- John Taylor-Johnston - ' ' ' Collège de Sherbrooke: ô¿ô http://www.collegesherbrooke.qc.ca/languesmodernes/ - Université de Sherbrooke: http://compcanlit.ca/ 819-569-2064
Re: [PHP] if(isset($submit))
Type image is great to use! Just make sure that when you are testing for the image variable you test for the x and y coordinates.. So name_x and name_y. Even better and a good habit would to make sure you have a hidden field with the same name as your submit button, because a lot of people including myself like to just hit enter instead of actually clicking on submit.. And when you just hit enter the submit button value isnt sent, but if you have that hidden field then that value will always be set. Happy Coding! Rick The human mind is not capable of grasping the Universe. We are like a little child entering a huge library. The walls are covered to the ceilings with books in many different tongues. The child knows that someone must have written these books. It does not know who or how. It does not understand the languages in which they are written. But the child notes a definite plan in the arrangement of the books---a mysterious order which it does not comprehend, but only dimly suspects. - Albert Einstein From: jtjohnston [EMAIL PROTECTED] Organization: FLSH, Université de Sherbrooke Reply-To: [EMAIL PROTECTED] Date: Thu, 28 Feb 2002 00:31:28 -0500 To: [EMAIL PROTECTED] Subject: Re: [PHP] if(isset($submit)) Nope, not following. :) More particularily why will isset accept type=submit and not type=image ? Martin Towell wrote: I used this code form action=/inetpub/wwwroot/top.html method=get input type=image src=none.gif width=125 height=25 name=submit value=submit /form when I clicked on the image, I got this url file:///C:/inetpub/wwwroot/top.html?submit.x=118submit.y=20 so php would get this as $submit_x and $submit_y HTH Martin -Original Message- From: jtjohnston [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 28, 2002 4:17 PM To: [EMAIL PROTECTED] Subject: [PHP] if(isset($submit)) Has anyone tried: input type=\image\ name=\submit\ value=\submit\ src=\next.gif\ border=\0\ align=\ABSCENTER\ instead of : input type=\submit\ name=\submit\ value=\\ I can't get this to work: if(isset($submit)) with: input type=\image\ name=\submit\ value=\submit\ src=\next.gif\ border=\0\ align=\ABSCENTER\ I'm not coding correctly? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- John Taylor-Johnston - ' ' ' Collège de Sherbrooke: ô¿ô http://www.collegesherbrooke.qc.ca/languesmodernes/ - Université de Sherbrooke: http://compcanlit.ca/ 819-569-2064 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] if(isset($submit))
Over kill? Martin Towell wrote: or have a hidden field, maybe, called submit -Original Message- From: jtjohnston [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 28, 2002 4:33 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] if(isset($submit)) So I can forget using type=image :( Wah, it's not fair! :) J Martin Towell wrote: I used this code form action=/inetpub/wwwroot/top.html method=get input type=image src=none.gif width=125 height=25 name=submit value=submit /form when I clicked on the image, I got this url file:///C:/inetpub/wwwroot/top.html?submit.x=118submit.y=20 so php would get this as $submit_x and $submit_y HTH Martin -Original Message- From: jtjohnston [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 28, 2002 4:17 PM To: [EMAIL PROTECTED] Subject: [PHP] if(isset($submit)) Has anyone tried: input type=\image\ name=\submit\ value=\submit\ src=\next.gif\ border=\0\ align=\ABSCENTER\ instead of : input type=\submit\ name=\submit\ value=\\ I can't get this to work: if(isset($submit)) with: input type=\image\ name=\submit\ value=\submit\ src=\next.gif\ border=\0\ align=\ABSCENTER\ I'm not coding correctly? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- John Taylor-Johnston - ' ' ' Collège de Sherbrooke: ô¿ô http://www.collegesherbrooke.qc.ca/languesmodernes/ - Université de Sherbrooke: http://compcanlit.ca/ 819-569-2064 -- John Taylor-Johnston - ' ' ' Collège de Sherbrooke: ô¿ô http://www.collegesherbrooke.qc.ca/languesmodernes/ - Université de Sherbrooke: http://compcanlit.ca/ 819-569-2064
Re: [PHP] Re: !isset ??
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
Re: [PHP] if(isset($a)) vs if($a)
In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Mark) wrote: if(isset($) and !empty($a) and !$a) this is the same as if(!empty($a)) or if(isset($) and $a===FALSE) this is the same as if(empty($a)) (Aside from accidentally omitted the a in the var name...oops...) No, they're not the same thing if you have error reporting set to E_ALL. If $a is not set, calling empty($a) or !$a produces a warning. -- CC -- 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]
Re: [PHP] if(isset($a)) vs if($a)
On Sun, 16 Sep 2001 09:18:23 -0700, CC Zona wrote: In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Mark) wrote: if(isset($) and !empty($a) and !$a) this is the same as if(!empty($a)) or if(isset($) and $a===FALSE) this is the same as if(empty($a)) Aside from accidentally omitted the a in the var name...oops...) No, they're not the same thing if you have error reporting set to E_ALL. If $a is not set, calling empty($a) or !$a produces a warning. calling empty($a) does not give a warning. -- Mark, [EMAIL PROTECTED] on 09/16/2001 -- 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]
Re: [PHP] if(isset($a)) vs if($a)
In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Mark) wrote: calling empty($a) does not give a warning. Sheesh. It doesn't at that. WTF? -- CC -- 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]
Re: [PHP] if(isset($a)) vs if($a)
In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Andrew Perevodchik) wrote: JD isset checks to see if the $a variable has JD been set, ie, if it exists. if($a) checks for JD the truthood of $a, meaning, if it has a JD non-zero, non-null/empty-string value, then JD its true, else, false. ... and if it's not set at all it returns a warning unless you use @ :( Or change the error_reporting level, or turn off display_errors (okay, technically the warning is still happening in the latter case, but IIRC that's also true of @--both simply suppress the *reporting* of the report rather than the *occurance* of the error). This is why it's best to do multiple checks and choose them carefully. Ex: if(isset($) and !empty($a) and !$a) or if(isset($) and $a===FALSE) etc. -- CC -- 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]
Re: [PHP] if(isset($a)) vs if($a)
On Sat, 15 Sep 2001 13:20:59 -0700, CC Zona wrote: In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Andrew Perevodchik) wrote: JD isset checks to see if the $a variable has JD been set, ie, if it exists. if($a) checks for JD the truthood of $a, meaning, if it has a JD non-zero, non-null/empty-string value, then JD its true, else, false. ... and if it's not set at all it returns a warning unless you use @ :( Or change the error_reporting level, or turn off display_errors (okay, technically the warning is still happening in the latter case, but IIRC that's also true of @--both simply suppress the *reporting* of the report rather than the *occurance* of the error). This is why it's best to do multiple checks and choose them carefully. Ex: if(isset($) and !empty($a) and !$a) this is the same as if(!empty($a)) or if(isset($) and $a===FALSE) this is the same as if(empty($a)) -- 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]
RE: [PHP] if(isset($a)) vs if($a)
isset checks to see if the $a variable has been set, ie, if it exists. if($a) checks for the truthood of $a, meaning, if it has a non-zero, non-null/empty-string value, then its true, else, false. jack -Original Message- From: David Yee [mailto:[EMAIL PROTECTED]] Sent: Friday, September 14, 2001 6:04 PM To: [EMAIL PROTECTED] Subject: [PHP] if(isset($a)) vs if($a) Hi. What is the difference between: if(isset($a)) and if($a) ??? Thanks. David -- 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]
RE: [PHP] weird isset problem
I see one typo, is that the problem? Kirk Hi! I have this weird thing happening here and I just can't see the problem. Can someone look at this and tell me if you see what is wrong? Code print isset($config["harvester_list"]) ."\n1\n"; print isset($config["download_list"]) . "\n2\n"; print isset($config["linkchecker_list"]) . "\n3\n"; print isset($config["offline_list"]) . "\n4\n"; print isset($config["spider_list"]) . "\n5\n"; # harvester is misspelled in the next line if (!isset($config["havester_list"]) || !isset($config["download_list"]) || !isset($config["linkchecker_list"]) || !isset($config["offline_list"]) || !isset($config["spider_list"])) { print "-\n"; print isset($config["harvester_list"]) ."\n1\n"; print isset($config["download_list"]) . "\n2\n"; print isset($config["linkchecker_list"]) . "\n3\n"; print isset($config["offline_list"]) . "\n4\n"; print isset($config["spider_list"]) . "\n5\n"; die("Agent Automated System Lists Not Found!\n"); } -- 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]
Re: [PHP] weird isset problem
What are you wanting to print? Here's a set of examples that may help understand what's happening with your code. In short, isset() is not being used properly. // if $var is set, this will return 1. if not set then it will return 0. // essentially, you don't want to print this directly as you've seen, it // gives us 1 or 0. isset($var) // these checks check for true. if ( isset($var) == true ) { print 'this is set'; } if ( isset($var) == 1 ) { print 'this is set'; } if ( isset($var) ) { print 'this is set'; } // these checks check for false. if ( isset($var) == false ) { print 'this is not set'; } if ( isset($var) == 0 ) { print 'this is not set'; } if ( !isset($var) ) { print 'this is not set'; } // This will check whether $var is empty but this way causes error if // error_reporting setting E_NOTICE is on (undefined variable) if ($var) { print 'this is set'; } Which brings us to empty(), empty is similar to isset, here's an example of difference : $var = 0; if ( empty($var) ) { print 'this will print if $var is not set,0, or empty "" '; } if ( isset($var) ) { print 'this is set, could be set to anything, including 0 or "" '; } Wow this got long, hopefully it makes sense :) regards, philip On Thu, 29 Mar 2001, Matthew Hanna wrote: Hi! I have this weird thing happening here and I just can't see the problem. Can someone look at this and tell me if you see what is wrong? Below is a code snippet I am using and the output from the code. As can be seen in the output all the $config[*] stuff are set. The if statement still gets executed though as if one or more $config[*] isn't set. Inside of the if statement I checked again and sure enough, they are still set even though the program makes it into the if statement. I am so confused. Thanks in advance! Matthew Hanna [EMAIL PROTECTED] Code print isset($config["harvester_list"]) ."\n1\n"; print isset($config["download_list"]) . "\n2\n"; print isset($config["linkchecker_list"]) . "\n3\n"; print isset($config["offline_list"]) . "\n4\n"; print isset($config["spider_list"]) . "\n5\n"; if (!isset($config["havester_list"]) || !isset($config["download_list"]) || !isset($config["linkchecker_list"]) || !isset($config["offline_list"]) || !isset($config["spider_list"])) { print "-\n"; print isset($config["harvester_list"]) ."\n1\n"; print isset($config["download_list"]) . "\n2\n"; print isset($config["linkchecker_list"]) . "\n3\n"; print isset($config["offline_list"]) . "\n4\n"; print isset($config["spider_list"]) . "\n5\n"; die("Agent Automated System Lists Not Found!\n"); } Output - 1 1 1 2 1 3 1 4 1 5 - 1 1 1 2 1 3 1 4 1 5 Agent Automated System Lists Not Found! -- 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]
RE: [PHP] Not isset
how do I write a Not isset as in: if != isset($order) { $order=$Table."ID"; } if( !( isset( $order ))) { } I'm big on parens. :p OR if( empty( $order )) { } Chris
RE: [PHP] Not isset
try if(!(isset($order))) { $order=$Table."ID"; } hth Thank you Brian Paulson Sr. Web Developer [EMAIL PROTECTED] http://www.chieftain.com 1-800-269-6397 -Original Message- From: Mike [mailto:[EMAIL PROTECTED]] Sent: Friday, March 09, 2001 1:34 PM To: [EMAIL PROTECTED] Subject: [PHP] Not isset how do I write a Not isset as in: if != isset($order) { $order=$Table."ID"; } mikep [EMAIL PROTECTED] -- 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 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]