Re: [PHP] If/else conditional statement ...

2001-12-23 Thread Casey Allen Shobe

On Sunday 23 December 2001 03:11 pm, Robert Dyke wrote:
> <% If $varA == True Then %>
> Straight HTML in here that only displays if $varA == True
> <% Else %>
> Straight HTML in here that only displays if $varA != True
> <% End if %>


$varA was true.

$varA was false.


I heavily dislike this coding style, however, and personally would use 
something like this:

$varA was ');
if ($varA == true) {
print ('true');
} else {
print ('false');
}
print ('.'."\n");
?>

-- 
Casey Allen Shobe
[EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] If/else conditional statement ... in an include file ...

2001-12-23 Thread Robert Dyke

I apologize for not including all of the information.  I did this as an
include file, which explains why it isn't working:

< !--- beginning of myinclude.php  >



< ! --- end of myinclude.php --- >



< !  beginning of testfile.php --- >

Html here that should display only if $varA  == True

< ?
}  // generic parser error generated here
Else {
?>

HTML that only displays if $varA != True


< ! - End of testfile.php  >


In ASP this works, in PHP it doesn't ... any ideas?


"Michael Sims" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> At 01:11 PM 12/23/2001 -0700, Robert Dyke wrote:
> >Hello:
> >
> >In ASP I can write a Conditional statement like this:
> >
> ><% If $varA == True Then %>
> >Straight HTML in here that only displays if $varA == True
> ><% Else %>
> >Straight HTML in here that only displays if $varA != True
> ><% End if %>
> >
> >Translating this to PHP doesn't work:
> >
> >   // error is generated here ...
> >
> >
> >Is there some way to do it this way in PHP?  I'd rather not create a huge
> >variable and then echo that.
>
> As others have pointed out, the above should work provided that you are
> terminating your curly braces properly.
>
> Another (perhaps easier) option would be to use "alternate syntax" which
is
> more similar to VBScript.  For example, the following works in PHP:
>
> 
> ...html...
> 
> ...html...
> 
>
> Note the colon's which are required.  The endif will need a semicolon if
> there are any other commands after it in the same code block.  Also, I
> don't believe you can mix alternate syntax and normal syntax in the same
> control structure.  For example, the following will probably give an
error:
>
>  if (condition):
>  if (other condition) {
>  do stuff
>  }
> endif;
> ?>
>
> You'd have to use alternate syntax on the nested if statement as well...
>
> I personally prefer alternate syntax when I'm breaking into and out of PHP
> a lot, like the example above.  For more info:
>
> http://www.php.net/manual/en/control-structures.alternative-syntax.php
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] If/else conditional statement ...

2001-12-23 Thread Michael Sims

At 01:11 PM 12/23/2001 -0700, Robert Dyke wrote:
>Hello:
>
>In ASP I can write a Conditional statement like this:
>
><% If $varA == True Then %>
>Straight HTML in here that only displays if $varA == True
><% Else %>
>Straight HTML in here that only displays if $varA != True
><% End if %>
>
>Translating this to PHP doesn't work:
>
>   // error is generated here ...
>
>
>Is there some way to do it this way in PHP?  I'd rather not create a huge
>variable and then echo that.

As others have pointed out, the above should work provided that you are 
terminating your curly braces properly.

Another (perhaps easier) option would be to use "alternate syntax" which is 
more similar to VBScript.  For example, the following works in PHP:


...html...

...html...


Note the colon's which are required.  The endif will need a semicolon if 
there are any other commands after it in the same code block.  Also, I 
don't believe you can mix alternate syntax and normal syntax in the same 
control structure.  For example, the following will probably give an error:



You'd have to use alternate syntax on the nested if statement as well...

I personally prefer alternate syntax when I'm breaking into and out of PHP 
a lot, like the example above.  For more info:

http://www.php.net/manual/en/control-structures.alternative-syntax.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] If/else conditional statement ...

2001-12-23 Thread Bogdan Stancescu

Took a better look at your code -- you've capitalized "true" -- that may be
it.

Bogdan


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] If/else conditional statement ...

2001-12-23 Thread Miles Thompson

What's the error, just a parse error on line xx?
O tend to do a lot of echo 'ing, so this suggestion may not be much help.
How about adding a semicolon?


Miles

At 01:11 PM 12/23/2001 -0700, Robert Dyke wrote:
>Hello:
>
>In ASP I can write a Conditional statement like this:
>
><% If $varA == True Then %>
>Straight HTML in here that only displays if $varA == True
><% Else %>
>Straight HTML in here that only displays if $varA != True
><% End if %>
>
>Translating this to PHP doesn't work:
>
>   // error is generated here ...
>
>
>Is there some way to do it this way in PHP?  I'd rather not create a huge
>variable and then echo that.
>
>Thanks in advance.
>
>
>Robert Dyke
>Montana Software
>http://www.montanasoft.com/
>[EMAIL PROTECTED]
>
>* For the best results please include the text of this message (cut and
>paste if necessary) in your reply *
>
>
>
>
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] If/else conditional statement ...

2001-12-23 Thread Bogdan Stancescu

Make sure you close the accolade afterwords in PHP -- other than that, yes,
it works just fine!

For example this should work just fine:
-

  Found a multiple of three!

--

Bogdan

Robert Dyke wrote:

> Hello:
>
> In ASP I can write a Conditional statement like this:
>
> <% If $varA == True Then %>
> Straight HTML in here that only displays if $varA == True
> <% Else %>
> Straight HTML in here that only displays if $varA != True
> <% End if %>
>
> Translating this to PHP doesn't work:
>
>// error is generated here ...
>
> Is there some way to do it this way in PHP?  I'd rather not create a huge
> variable and then echo that.
>
> Thanks in advance.
>
> Robert Dyke
> Montana Software
> http://www.montanasoft.com/
> [EMAIL PROTECTED]
>
> * For the best results please include the text of this message (cut and
> paste if necessary) in your reply *
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] If/else conditional statement ...

2001-12-23 Thread Robert Dyke

Hello:

In ASP I can write a Conditional statement like this:

<% If $varA == True Then %>
Straight HTML in here that only displays if $varA == True
<% Else %>
Straight HTML in here that only displays if $varA != True
<% End if %>

Translating this to PHP doesn't work:

   // error is generated here ...


Is there some way to do it this way in PHP?  I'd rather not create a huge
variable and then echo that.

Thanks in advance.


Robert Dyke
Montana Software
http://www.montanasoft.com/
[EMAIL PROTECTED]

* For the best results please include the text of this message (cut and
paste if necessary) in your reply *






-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]