开发者

Jump to another line of code in mixed PHP/HTML document

I would like to ask probably simple question. Consider following php page:

<p>Name of my town is:</p>
<?php echo "London"; 
//if ($condition=="dad_display") then display dad'to开发者_如何学JAVAwn, else display mum's town. 
?>

<p>Name of dad's town is:</p>
<?php echo "Prague"; ?>

<p>Name of mum's town is:</p>
<?php echo "Berlin"; ?>

is there any way how to circumvent HTML/PHP code inbetween desired beginning and target line of code? (I can not use goto statement...) and I DO NOT want to echo every single HTML line manually (cause in my real page there is a bunch of html code). Otherwise it would be easy.

Thanks very much for reply.


Probably the alternative syntax of PHP conditional would be best; it's designed to be mixed into the page code.

<p>Name of my town is:</p>
<?php echo "London"; ?>

<?php if ($condition=="dad_display"): ?> 

<p>Name of dad's town is:</p>
<?php echo "Prague"; ?>

<?php else: ?>

<p>Name of mum's town is:</p>
<?php echo "Berlin"; ?>

<?php endif; ?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜