php-general Digest 20 Feb 2013 12:42:05 -0000 Issue 8130

Topics (messages 320246 through 320256):

Re: parsing select multiple="multiple"
        320246 by: Jim Giner

Re: [PHP-DEV] PHP 5.3.22RC1 and 5.4.12RC1 Released for Testing!
        320247 by: Jan Ehrhardt
        320248 by: Johannes Schlüter
        320249 by: Stas Malyshev
        320250 by: Jan Ehrhardt

phpinfo()
        320251 by: John Taylor-Johnston
        320254 by: Ashley Sheridan
        320256 by: Design in Motion Webdesign

if (empty versus if (isset
        320252 by: John Taylor-Johnston
        320253 by: Adam Richardson
        320255 by: marco.behnke.biz

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
On 2/19/2013 2:02 PM, John Taylor-Johnston wrote:

tamouse mailing lists wrote:
>I hate arrays. :D
Here's a small snippet showing how it works, I hope:

foreach ($DPRpriority as $item => $value) {
   echo "<li> ".$item.": ".$value['name']." selected:
".$value['selected']." </li>\n";
}

Question 1: when did we have to add [] to a <input> name to turn it into
an array?

<input type="checkbox" name="DPRlocationdetails[]" value="Unknown">

According to phpinfo() it still comes out as
$_POST['DPRlocationdetails'] without [].

Are the [] necessary?
----------------------------------------------
Question 2:
I was looking at some code in the Manual, where someone used isset and
is_array.

How necessary is if(isset($_POST['DPRlocationdetails']))

and then to use: if(is_array($_POST['DPRlocationdetails']))

That seems like over kill?
----------------------------------------------
Question 3:

My code works, perfectly. In this case, I decided to attack some
check-boxes first. The resulting function will work for <select
multiple> too..

Does anyone see me doing something wrong in my code below?

My questions are:

Is this the only way to pass "Unknown", "Family Home" or "Apartment"
into the function?

Is this correct?

---- if ($_POST['DPRlocationdetails'] == "Unknown")

Somebody once told me I had to do it this way?

---- if ("Unknown" == $_POST['DPRlocationdetails'])

John

--------------------snip---------------------------

<form action="foo.php" id="DPRform" method="post"><input value="Update"
type="submit">
<input type="checkbox" name="DPRlocationdetails[]" value="Unknown" <?php
filter_value($_POST['DPRlocationdetails'],"Unknown"); ?>> Unknown
<input type="checkbox" name="DPRlocationdetails[]" value="Family Home"
<?php filter_value($_POST['DPRlocationdetails'],"Family Home"); ?>>
Family Home
<input type="checkbox" name="DPRlocationdetails[]" value="Apartment"
<?php filter_value($_POST['DPRlocationdetails'],"Apartment"); ?>> Apartment
</form>

<?php
function filter_value($tofilter,$tofind) {
foreach($tofilter as $value){
     if ($value == $tofind) echo "checked";
     }
}
?>


The [] are necessary if there are going to be multiple occurrences of an input with the same name, hence the [] to allow your php script to extract all of the occurrences.

Using isset and is_array comes in handy to help you handle the incoming var properly. If it IS set, you then have to check if there is only one value (hence a string) or if there are multiple values (an array).

#3 - no idea what you are asking.       

--- End Message ---
--- Begin Message ---
Johannes Schlüter in php.internals (Thu, 31 Jan 2013 16:00:17 +0100):
>If no critical issues is found in this RC, the final version will be
>released in two weeks.

Just curious: what is keeping 5.3.22 and 5.4.12 from being released?
Are there any issues?

Jan

--- End Message ---
--- Begin Message ---
On Wed, 2013-02-20 at 00:13 +0100, Jan Ehrhardt wrote:
> Johannes Schlüter in php.internals (Thu, 31 Jan 2013 16:00:17 +0100):
> >If no critical issues is found in this RC, the final version will be
> >released in two weeks.
> 
> Just curious: what is keeping 5.3.22 and 5.4.12 from being released?
> Are there any issues?

As a look on qa.php.net or the box on the top right of php.net tells we
have RC2 for both out, you can also see in the repo that the release is
being prepared:

http://git.php.net/?p=php-src.git;a=blobdiff;f=NEWS;h=d3a3e9fa0f344d9b736ea17ce408df6b02e8b561;hp=c4262020de69b7a93b8fcf4923e85194756435a7;hb=0183c29cb3921926855ed6f5e7cea7851fb8a5a1;hpb=904d2202eaecb7c300c36f37ebc5503513220c09

Please test the RCs and provide test feedback. Thanks.

johannes



--- End Message ---
--- Begin Message ---
Hi!

> Johannes Schlüter in php.internals (Thu, 31 Jan 2013 16:00:17 +0100):
>> If no critical issues is found in this RC, the final version will be
>> released in two weeks.
> 
> Just curious: what is keeping 5.3.22 and 5.4.12 from being released?
> Are there any issues?

We had 5.4.12 RC2 last week, due to recent SOAP fixes we had to pull in,
and will have 5.4.12 GA this week.


-- 
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

--- End Message ---
--- Begin Message ---
Stas Malyshev in php.internals (Tue, 19 Feb 2013 15:35:54 -0800):
>> Johannes Schlüter in php.internals (Thu, 31 Jan 2013 16:00:17 +0100):
>>> If no critical issues is found in this RC, the final version will be
>>> released in two weeks.
>> 
>> Just curious: what is keeping 5.3.22 and 5.4.12 from being released?
>> Are there any issues?
>
>We had 5.4.12 RC2 last week, due to recent SOAP fixes we had to pull in,
>and will have 5.4.12 GA this week.

OK. Johannes' reply made me think I mistook the final RC for the
release, but you seem to indicate there was indeed a little delay.

For Johannes: building 5.3.22 and 5.4.12 (both NTS, Windows) right now.
I will report back if I run into something.

Jan

--- End Message ---
--- Begin Message --- I cannot find button2 in phpinfo() when I click it. I was hoping to find a $_POST["button2"] value.
What am I doing wrong?

<input type="button" name="button2" id="button2" value="Print Mode" onclick="formSubmit()">

I really wanted to use a button to pass a different condition than a <input type="submit">
--- End Message ---
--- Begin Message ---

John Taylor-Johnston <john.taylor-johns...@cegepsherbrooke.qc.ca> wrote:

>I cannot find button2 in phpinfo() when I click it. I was hoping to
>find 
>a $_POST["button2"] value.
>What am I doing wrong?
>
><input type="button" name="button2" id="button2" value="Print Mode" 
>onclick="formSubmit()">
>
>I really wanted to use a button to pass a different condition than a 
><input type="submit">

Use a different value or name on the <input type="submit"/> button. Don't use 
JavaScript to trigger the form like that. Its not necessary and will bite you 
in the ass if ypu get a visitor who browses without JavaScript, which can 
include security aware users, blind users, etc
Thanks,
Ash
http://www.ashleysheridan.co.uk

--- End Message ---
--- Begin Message ---



John Taylor-Johnston <john.taylor-johns...@cegepsherbrooke.qc.ca> wrote:

I cannot find button2 in phpinfo() when I click it. I was hoping to
find
a $_POST["button2"] value.
What am I doing wrong?

<input type="button" name="button2" id="button2" value="Print Mode"
onclick="formSubmit()">

I really wanted to use a button to pass a different condition than a
<input type="submit">

Use a different value or name on the <input type="submit"/> button. Don't use JavaScript to trigger the form like that. Its not necessary and will bite you in the ass if ypu get a visitor who browses without JavaScript, which can include security aware users, blind users, etc
Thanks,
Ash
http://www.ashleysheridan.co.uk

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


Try $_POST['button2']

Best regards.
Steven


--- End Message ---
--- Begin Message ---
What is the difference between?

if (empty... http://www.php.net/manual/en/function.empty.php "Determine whether a variable is empty"
and
if (isset... http://php.net/manual/en/function.isset.php "Determine if a variable is set and is not *|NULL|*"

I have an <input type="radio" value="something">.

If it is not checked, it is NOT empty, because it has a value, right?
But it is NOT set, right?

Is this empty, because it's value is ""?

<input type="text" value="">

Just trying to understand ... :)

--- End Message ---
--- Begin Message ---
On Tue, Feb 19, 2013 at 9:29 PM, John Taylor-Johnston
<john.taylor-johns...@cegepsherbrooke.qc.ca> wrote:
>
> What is the difference between?
>
> if (empty... http://www.php.net/manual/en/function.empty.php "Determine 
> whether a variable is empty"
> and
> if (isset... http://php.net/manual/en/function.isset.php "Determine if a 
> variable is set and is not *|NULL|*"


I like the explanation on the empty page:

"No warning is generated if the variable does not exist. That means
empty() is essentially the concise equivalent to !isset($var) || $var
== false."


> I have an <input type="radio" value="something">.
>
> If it is not checked, it is NOT empty, because it has a value, right?
> But it is NOT set, right?

Some of the form elements (e.g., checkboxes, radio's) are a little tricky:
http://stackoverflow.com/questions/476426/submit-an-html-form-with-empty-checkboxes

When unchecked, no GET or POST variable is present to represent their value.

> Is this empty, because it's value is ""?
>
> <input type="text" value="">
>
> Just trying to understand ... :)

A text field would be present in the GET or POST super globals, and if
empty (the user did not add input), the empty function would return
true because an empty string is one of the values that evaluates to
false:
- "" (an empty string)
- 0 (0 as an integer)
- 0.0 (0 as a float)
- "0" (0 as a string)
- NULL
- FALSE
- array() (an empty array)
- $var; (a variable declared, but without a value)

Adam

--
Nephtali:  A simple, flexible, fast, and security-focused PHP framework
http://nephtaliproject.com

--- End Message ---
--- Begin Message ---
isset checks if something is defined or if an array has a key with a value other
than null

read:
http://www.php.net/manual/en/function.isset.php#refsect1-function.isset-returnvalues

empty check isset PLUS if the value is not null, false, 0 and wahtever php
thinks is empty

read:
http://www.php.net/manual/en/function.empty.php#refsect1-function.empty-returnvalues

You should also checkout array_key_exists

read: http://www.php.net/manual/en/function.array-key-exists.php

> John Taylor-Johnston <john.taylor-johns...@cegepsherbrooke.qc.ca> hat am 20.
> Februar 2013 um 03:29 geschrieben:
>
>
> What is the difference between?
>
> if (empty... http://www.php.net/manual/en/function.empty.php "Determine
> whether a variable is empty"
> and
> if (isset... http://php.net/manual/en/function.isset.php "Determine if a
> variable is set and is not *|NULL|*"
>
> I have an <input type="radio" value="something">.
>
> If it is not checked, it is NOT empty, because it has a value, right?
> But it is NOT set, right?
>
> Is this empty, because it's value is ""?
>
> <input type="text" value="">
>
> Just trying to understand ... :)

--
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz

--- End Message ---

Reply via email to