PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > Control structures
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Control structures

Réponse
 
LinkBack Outils de la discussion
Vieux 05/11/2007, 21h42   #1
pgt
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Control structures

I need to cease the execution of some code if a couple of conditions are not
met.

exit; destroys the rest of my page of course, so I *think* I need some sort
of "wrapper", perhaps in a control structure?

The page works flawlessly otherwise (and reporting is set to
error_reporting(E_ALL); )


<body>
<div>
<?php
if (error checking here)
{echo 'error message';}
elseif (secondary error checking here)
{echo 'more error messages';}
// exit; <!--destroys rest of the page, so can't use-->
?>

<CONTAINER>
<?php
// other stuff
?>
</CONTAINER>

<!-- other html -->
</div>
</body>


I need to NOT execute anything within 'CONTAINER' when the if/elseif
statements are not met, but I DO need to continue with the html above the
closing div, so the rest of the page displays normally.

How to "wrap" this? Or ... ?


  Réponse avec citation
Vieux 05/11/2007, 23h42   #2
yawnmoth
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Control structures

On Nov 5, 3:42 pm, "pgt" <pgt...@gmail.not> wrote:
> I need to cease the execution of some code if a couple of conditions are not
> met.
>
> exit; destroys the rest of my page of course, so I *think* I need some sort
> of "wrapper", perhaps in a control structure?
>
> The page works flawlessly otherwise (and reporting is set to
> error_reporting(E_ALL); )
>
> <body>
> <div>
> <?php
> if (error checking here)
> {echo 'error message';}
> elseif (secondary error checking here)
> {echo 'more error messages';}
> // exit; <!--destroys rest of the page, so can't use-->
> ?>
>
> <CONTAINER>
> <?php
> // other stuff
> ?>
> </CONTAINER>
>
> <!-- other html -->
> </div>
> </body>
>
> I need to NOT execute anything within 'CONTAINER' when the if/elseif
> statements are not met, but I DO need to continue with the html above the
> closing div, so the rest of the page displays normally.
>
> How to "wrap" this? Or ... ?


<body>
<div>
<?php
$skip=false;
if (error checking here)
{echo 'error message';$skip=true;}
elseif (secondary error checking here)
{echo 'more error messages';$skip=true;}
// exit; <!--destroys rest of the page, so can't use-->
?>

<CONTAINER>
<?php
if (!$skip){
// other stuff
}
?>
</CONTAINER>

<!-- other html -->
</div>
</body>

I think that does what you want? I just added a new variable $skip...

  Réponse avec citation
Vieux 06/11/2007, 19h56   #3
pgt
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Control structures


"yawnmoth" <terra1024@yahoo.com> wrote in message
news:1194306145.402907.32110@o38g2000hse.googlegro ups.com...
> On Nov 5, 3:42 pm, "pgt" <pgt...@gmail.not> wrote:
>> I need to cease the execution of some code if a couple of conditions are
>> not
>> met.
>>
>> exit; destroys the rest of my page of course, so I *think* I need some
>> sort
>> of "wrapper", perhaps in a control structure?
>>
>> The page works flawlessly otherwise (and reporting is set to
>> error_reporting(E_ALL); )
>>
>> <body>
>> <div>
>> <?php
>> if (error checking here)
>> {echo 'error message';}
>> elseif (secondary error checking here)
>> {echo 'more error messages';}
>> // exit; <!--destroys rest of the page, so can't use-->
>> ?>
>>
>> <CONTAINER>
>> <?php
>> // other stuff
>> ?>
>> </CONTAINER>
>>
>> <!-- other html -->
>> </div>
>> </body>
>>
>> I need to NOT execute anything within 'CONTAINER' when the if/elseif
>> statements are not met, but I DO need to continue with the html above the
>> closing div, so the rest of the page displays normally.
>>
>> How to "wrap" this? Or ... ?

>
> <body>
> <div>
> <?php
> $skip=false;
> if (error checking here)
> {echo 'error message';$skip=true;}
> elseif (secondary error checking here)
> {echo 'more error messages';$skip=true;}
> // exit; <!--destroys rest of the page, so can't use-->
> ?>
>
> <CONTAINER>
> <?php
> if (!$skip){
> // other stuff
> }
> ?>
> </CONTAINER>
>
> <!-- other html -->
> </div>
> </body>
>
> I think that does what you want? I just added a new variable $skip...



Thank you so much. Couldn't see the wood because the forest got in the way
;-)

Much appreciated :-))







  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 19h22.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,09191 seconds with 11 queries