469,358 Members | 1,541 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,358 developers. It's quick & easy.

CHecking variable Existence

Hey guys, I want to PHP to do stuff only if a sertain form variable exists.
How do i check to see if a variable exists or not?

Something like If $http_post_vars['name'] exists, then do this.

syntax please? :)
Jul 17 '05 #1
5 7724
I noticed that Message-ID: <Of*****************@fe1.texas.rr.com> from
Tesla contained the following:
Something like If $http_post_vars['name'] exists, then do this.

syntax please? :)


yes. :)
if($http_post_vars['name']){do this}

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #2
Geoff Berrow a écrit le 20/02/2004 :
Something like If $http_post_vars['name'] exists, then do this.

syntax please? :)


yes. :)
if($http_post_vars['name']){do this}


I prefer using isset() function : http://www.php.net/isset
Jul 17 '05 #3
In article <me********************************@free.fr.Remove this>,
Jedi121 <je*********@free.fr.Removethis> wrote:
if($http_post_vars['name']){do this}


I prefer using isset() function : http://www.php.net/isset


I have a similar issue as the first poster.

isset($_POST['name']) works, as does if ($_POST['name']!=NULL) . The
problem is that, if error_reporting is set to E_ALL, both of those will
pop up an error that says "Notice: Undefined index: name" at the top of
the page. Yes, you can make that go away by setting error_reporting to
ignore Notices, but when I'm testing scripts I like to keep it on E_ALL
so I know if I'm doing something that's not fatal but still stupid.

So is there a way to check for a variable's existence without PHP
whining if it doesn't exist? :P

if ($POST['name']) seems to always evaluate as true in my tests -- as
well as pop up a Notice.
Jul 17 '05 #4
Garrett Albright <g_******************@ya-nospam-hoo.com> schrieb:
isset($_POST['name']) works, as does if ($_POST['name']!=NULL) . The
problem is that, if error_reporting is set to E_ALL, both of those will
pop up an error that says "Notice: Undefined index: name" at the top of
the page.


isset($_POST['name']) shouldn't give a notice. Please recheck that.

Regards,
Matthias
Jul 17 '05 #5
In article <c1**********@usenet.esken.de>,
Matthias Esken <mu******************@usenetverwaltung.org> wrote:
isset($_POST['name']) shouldn't give a notice. Please recheck that.


Recheck I did, and it did not give a notice. I must have had an error
elsewhere in the code. My bad. :/
Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Bart Nessux | last post: by
5 posts views Thread by Thierry S. | last post: by
4 posts views Thread by GujuBoy | last post: by
1 post views Thread by Xeno Campanoli | last post: by
2 posts views Thread by mike | last post: by
5 posts views Thread by Richard L Rosenheim | last post: by
6 posts views Thread by Vmusic | last post: by
4 posts views Thread by Patient Guy | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.