![]() |
PHP coders - quick question
How do I do this:
IF $_GET['cat'] = 0 OR $_GET['cat'] IS NULL myCat = 0 else myCat = $_GET['cat'] END IF Basically, if there is a request var called "cat" and it is zero, null, or if it doesn't even exist, set a var myCat to zero. Otherwise, set the var to whatever it currently contains. Thanks in advance! |
if(!empty($_GET['cat']))
$myCat = $_GET['cat']; else $myCat = defaultValue; |
Quote:
|
as far as I know in newer versions of PHP, 0 is empty.. you can also use
!isset($_GET['cat']) if !empty() doesn't work out for ya :) |
Thanks very much! It works well.
|
empty($_GET["cat"]) ? ($myCat=0) : ($myCat=$_GET["cat"]);
That's basically what i use. |
i use isset
|
Quote:
aric, do u have a site or offer programming services? lmk... i have a project if u r available - thanks! ... |
if($_GET['cat'] < 1){$_GET['cat']=0}
|
if cat is a numeric value, like a category id or something, you can do:
$myCat=intval($_GET['cat']); |
WHEN WILL YOU LEARN!?!?!?!? "Quick Questions" NEVER have "quick answers".
|
All times are GMT -7. The time now is 10:36 PM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123