Forum Moderators: coopster

Message Too Old, No Replies

why the difference

         

kumarsena

11:54 am on Sep 20, 2004 (gmt 0)

10+ Year Member



just wondering

why is this

$_POST['sect_name'] = $sectname;

different form this

$sectname = $_POST['sect_name'];

the latter works, but the first

just wondering...

eggy ricardo

3:20 pm on Sep 20, 2004 (gmt 0)

10+ Year Member



From what i know of PHP the first sets the value of $_POST['sect_name'] to $sectname where as it is the other way round for the latter.

coopster

5:06 pm on Sep 20, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



It means that the the left operand gets set to the value of the expression on the right (that is, "gets set to"). See Assignment Operators [php.net] for more information.

paybacksa

4:11 am on Sep 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



just wondering, why is
$_POST['sect_name'] = $sectname;

different from
$sectname = $_POST['sect_name'];

the latter works, but the first

the first tries to stuff the contents of a variable $sectname into the POST array.

The second takes the value from the POST and puts it into a variable $sectname.

What works for you depends on what you are trying to do. If you want to take the values POSTed and start to use them in an array the second is your way. If you wanted to overwrite what was in the POST array, the first is your code.

kumarsena

8:58 am on Sep 21, 2004 (gmt 0)

10+ Year Member



thanks

that explained alot really,,,i got and error with the first way of doing it. i now realise it was because i didnt define (or is it declare?) $sectname. i was atttempting to do the latter, but didnt knwo the difference.