Page 1 of 1
accessing a variable using $_REQUEST even if it not exist
Posted: Wed Jun 16, 2004 8:08 am
by pelegk2
in asp when i access a variable that was sent to the server
i dont have to check if it exist or not i just can try to access and if it dosent exist
i get notjing back
is it possible in php so i will not have to use isset() every time?
thnaks in advance
peleg
Posted: Wed Jun 16, 2004 12:13 pm
by feyd
you can do it if you want.. you'll just get core notices in your error logs about it not existing...
Posted: Thu Jun 17, 2004 1:42 am
by pelegk2
yes i know that:)
i am looking for a solutiion that will pass it
Posted: Thu Jun 17, 2004 1:44 am
by feyd
error_reporting(E_ALL ^ E_NOTICE);
.. although you really should check whether the variables exist..
Posted: Thu Jun 17, 2004 2:39 am
by pelegk2
idont want to report on error!!!!
i want to be able to call like in asp avariable that event dosent exist!
and if not exist to get a blank empty or what ever variable
Posted: Thu Jun 17, 2004 2:51 am
by feyd
settle down. If you bothered to read what the function does, you'd realize that it turns off the notices..
you get a blank value already when you call an uninitialized variable...
Posted: Thu Jun 17, 2004 3:38 am
by pelegk2
belivem e i am ver very relax person:)
Posted: Thu Jun 17, 2004 3:39 am
by pelegk2
by the way :
i did read abut error_reporting but i dont want errors not to be messaged to me
i want to know all about them where and why
beacuse of that that function isnt good for me
Posted: Thu Jun 17, 2004 6:25 am
by magicrobotmonkey
who dont you write your own function? pass it a name and it checks isset and if it is it returns it and if not it returns whatever you want
Posted: Thu Jun 17, 2004 6:34 am
by JayBird
pelegk2 wrote:by the way :
i did read abut error_reporting but i dont want errors not to be messaged to me
i want to know all about them where and why
beacuse of that that function isnt good for me
feyd's solution turns off notices,
not errors.
Why would you want to call a variable that doesn't exist. That would just lead to problems and messy code in my opinion.
So the answer to your question is turn off notices or use isset(), not really that big of a deal is it!?
Mark
Posted: Thu Jun 17, 2004 7:50 am
by pelegk2
no not big deal but it takes all the air out of another funciotn i use