JV’s Power Tips for PHP (2) - Method 1
(Page 3 of 7 )
Anyway, back to the main point. We are in the middle of writing a script to test if the user has selected bold, italic etc. Here is the first (most basic) way of doing this:
<?php
if ( $_POST['bold'] )
{
$_POST['chat'] = "<b>{$_POST['chat']} </b>";
}
if ( $_POST['italic'] )
{
$_POST['chat'] = "<i>{$_POST['chat']}</i>";
}
if ( $_POST['underline'] )
{
$_POST['chat'] = "<u>{$_POST["chat']}</u>";
}
if ( $_POST['strike'] )
{
$_POST['chat'] = "<s>{$_POST['chat']}</s>";
}
echo $_POST['chat'];
?> It's easy to see what is going on here. So I won’t say too much about it. Except that it is worth noting the variable $_POST['chat'] is within {}'s. This means you don’t have to break the "'s with .s!
Next: Method 2 >>
More PHP Articles
More By Justin Vincent