Bluewalrus:
Twey means something like:
Code:<?php $var = "Hello"; if($var == "Hello"){?> You said Hello! <?php} ?>
Bluewalrus:
Twey means something like:
Code:<?php $var = "Hello"; if($var == "Hello"){?> You said Hello! <?php} ?>
Jeremy | jfein.net
Would that work for this? say $name was from a form on the previous page and was declared here.
----------------------------------------------------------------------PHP Code:<?php
$var = "Hello";
if($var == "Hello"){
?>
You said Hello $name !
<?php
}
?>
Code:<?php $var = "Hello"; if($var == "Hello"){ echo "You said Hello {$name} !"; } ?>
Kind of, but think of it in terms of the HTML and format accordingly, and you need to re-enter PHP parsing mode to output a variable. PHP also includes an alternative syntax for blocks to make this more readable (you get an ADA-like 'comb'):And the output:Code:<?php $var = 'Hello'; $name = 'John'; ?>Ah, you're right, Nile. Thanks!Code:<?php if ($var === 'Hello'): ?> You said hello, <?php echo $name; ?>! <?php endif; ?>
Edit: When formatting, I like to indent PHP blocks one block above the current element, since they tend to semantically associate with the outer element:Code:<div> <p> <?php if ($var === 'Hello'): ?> You said hello! <?php else: ?> You didn't say hello. <?php endif; ?> </p> </div>
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Only the $name bit didn't work; the idea bluewalrus was asking after (wrapping a piece of HTML in a PHP block) does. Sorry for the confusion; I've edited to make it clearer.![]()
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Thanks, I fixed it![]()
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Bookmarks