FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Parameter passing question
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Parameter passing question [message #173542 is a reply to message #173540] Mon, 18 April 2011 18:20 Go to previous messageGo to previous message
Chuck Lavin is currently offline  Chuck Lavin
Messages: 5
Registered: April 2011
Karma:
Junior Member
This is not a homework assignment. I'm working on a live remote server that
I'd rather not be playing around with.

According to the PHP doc page for isset(), isset() can't tell the difference
between a variable that's not set and a variable that's empty.

I need to move passed parameters into session variables:

1) If a parameter is passed with a value, set the session variable with that
value;

2) If a parameter is passed with an empty value, get rid of that session
variable;

3) If a parameter is not passed at all (not referenced in the URL), don't
touch the session variable.

And right now I can't tell the difference between a parameter being passed
empty and no parameter being passed at all.

Tnx
CL

"Denis McMahon" <denis(dot)m(dot)f(dot)mcmahon(at)gmail(dot)com> wrote in message
news:4dac7807$0$23634$bed64819(at)gradwell(dot)net...
> On Mon, 18 Apr 2011 13:03:24 -0400, Chuck Lavin wrote:
>
>> How do I tell these three passed parameters apart (PHP 5)?
>
>> http://www.somewhere.com?param=value // param has been set to 'value'
>> http://www.somewhere.com?param= // param has been set to empty (or
>> null)
>> http://www.somewhere.com // param has not been set at all
>
> This smells like it might be a homework question, or someone doing a
> w3schools online certification, but I'll bite.
>
> Have you tried something like the following:
>
> <?php
> if (isset($_GET['x'])) {
> if ($_GET['x'] == null) {
> // it's null
> } else {
> // it has data
> }
> } else {
> // it's not defined
> }
> ?>
>
> If you have tried it, did it do what you want, and if not how did it fail
> to do so[1]?
>
> If you haven't tried it, what have you tried so far?
>
> If you can't figure out what to use for x, please ask your teacher to
> revise passing parameters with you again.
>
> Rgds
>
> Denis McMahon
>
> [1] I don't think it quite does what you want, but I also think the
> change that needs to be made is trivial and you should be able to deduce
> it yourself.
>
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: &amp; - form and session problem!
Next Topic: doctype not found?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 22 06:51:21 GMT 2024

Total time taken to generate the page: 0.06083 seconds