You are here: Re: Use of isset () in a string variabel « PHP Programming Language « IT news, forums, messages
Re: Use of isset () in a string variabel

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация