|
Posted by Chris Hope on 05/10/05 08:30
Brian Olivier wrote:
> What I try to do is create a string variabel with some intelligence.
>
> I want this variabel to read the information sent by another page and
> interpret the result.
>
> The idea is that is a variabel is set, a line break is printed.
>
> First question is if this is possible? Second if so, what should be
> the correct syntax? I have written it like this, but this errors.
>
> $string="{$_POST['name']}{if (isset($_POST['name'])){print
> ("<br>");}";
You can't put code inside the curlies {} in a string.
I'm not sure I understand exactly what you are wanting to do, but if you
want to print a line break if the value is set, or do something else if
it is not, then you probably want to do it like this:
if(isset($_POST['name'])) {
// do something
}
else {
// do something else
}
If you want to assign the value to a variable you can do it like this:
$string = isset($_POST['name']) ? $_POST['name'] : "something else";
With this example, if $_POST['name'] is set then $string will be
populated with that value. If it's not then it will be populated with
"something else".
HTH
--
Chris Hope | www.electrictoolbox.com | www.linuxcdmall.com
Navigation:
[Reply to this message]
|