accessing a variable using $_REQUEST even if it not exist

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

accessing a variable using $_REQUEST even if it not exist

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you can do it if you want.. you'll just get core notices in your error logs about it not existing...
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post by pelegk2 »

yes i know that:)
i am looking for a solutiion that will pass it
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

error_reporting(E_ALL ^ E_NOTICE);

.. although you really should check whether the variables exist..
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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...
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post by pelegk2 »

belivem e i am ver very relax person:)
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post 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
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post 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
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post 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
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post by pelegk2 »

no not big deal but it takes all the air out of another funciotn i use
Post Reply