Bluewalrus:
Twey means something like:
Code:<?php
$var = "Hello";
if($var == "Hello"){
?>
You said Hello!
<?php
}
?>
Printable View
Bluewalrus:
Twey means something like:
Code:<?php
$var = "Hello";
if($var == "Hello"){
?>
You said Hello!
<?php
}
?>
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} !";
}
?>
No - that would not work...
@Twey, it's .net not .org:
http://www.smarty.net/
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>
Um.. it doesn't work.
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. :)
Ok.. sorry. :D
Also, your link has a .org, instead of .net(smarty).
Thanks, I fixed it :)