I would like a very nice PHP shortcut to dynamically setting a
variable value by embedding PHP commands inside, which is what I can
easily do in TCL:
set stuff "hello [if {[regexp {/dev} $env(HTTP_HOST)]} {set x "
devworld"} else {set x " world"}]"
in TCL this would set stuff to either "hello world" or, if you're in
/dev "hello devworld"
how can I accomplish this great TCL feature in PHP? I haven't found a
way yet, everything I have done has so far produced parse errors:
$stuff = "hello" . (if (preg_match('/\/dev/i', $HTTP_HOST)) { $stuff
..= ' devworld'; } else { $stuff .= ' world'; });
Phil
variable value by embedding PHP commands inside, which is what I can
easily do in TCL:
set stuff "hello [if {[regexp {/dev} $env(HTTP_HOST)]} {set x "
devworld"} else {set x " world"}]"
in TCL this would set stuff to either "hello world" or, if you're in
/dev "hello devworld"
how can I accomplish this great TCL feature in PHP? I haven't found a
way yet, everything I have done has so far produced parse errors:
$stuff = "hello" . (if (preg_match('/\/dev/i', $HTTP_HOST)) { $stuff
..= ' devworld'; } else { $stuff .= ' world'; });
Phil
Comment