This will be an easy question, but I'm having no luck figuring it out (after the whole 5 minutes I've spent - patience isn't one of my virtues
). Basically, if I have a user defined variable that isn't set, I just want to provide a default value. Make sense?
In javascript, I'd just use something like:
Code:
function whatever(arg1, arg2) {
var something = arg1 || "chris";
var something_else = arg2 || "topher";
}
With this PHP, it's just $_GET variable i'm using, so, although it's a different scope, I wouldn't've imagined it to be difficult. I initially thought using
[php]
$al = $_GET['something'] || "hi";
[/php]
might work, but it doesn't. What does PHP default $_GET variables to if they aren't present? I had presumed something like
[php]
if (is_null($_GET['something'])) {
$al = "hi";
} else {
$al = $_GET['something'];
}
//or use !is_string()...
[/php]
would work, but even though it does to an extent, i still get the PHP error 'undefined index'.
Anyway, there must be an obvious thing I'm missing here, as this seems very easy.
Cheers for any help