Welcome Guest, Not a member yet? Register   Sign In
initialize variables
#5

[eluser]Unknown[/eluser]
A perfect example is with a URL variable. Sometimes it may be there, sometimes not so instead of having an if block to test if it exists, you would use this type of function.

getVar($_GET['myvar'], 'default value');

It's a simple function that tests whether the variable exists and assigns it a default value if it doesn't so that you don't get warnings that "this variable does not exists".


Messages In This Thread
initialize variables - by El Forum - 10-13-2009, 02:33 PM
initialize variables - by El Forum - 10-13-2009, 06:05 PM
initialize variables - by El Forum - 10-13-2009, 06:45 PM
initialize variables - by El Forum - 10-13-2009, 07:03 PM
initialize variables - by El Forum - 10-14-2009, 09:15 AM
initialize variables - by El Forum - 10-14-2009, 10:24 AM



Theme © iAndrew 2016 - Forum software by © MyBB