problem with echoing this: echo("<input type="t
Moderator: General Moderators
problem with echoing this: echo("<input type="t
How can I use php's echo() to echo <input type="text" name="test">
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Or you can put it into single quotes and not have to worry about escaping:
For more info:
http://www.php.net/manual/en/language.types.string.php
Mac
Code: Select all
echo '<input type="text" name="test">';http://www.php.net/manual/en/language.types.string.php
Mac
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
when there's a lot of static html text you want to output it might increase readability (and speed) if you leave the php-block and enter a new one afterwards, e.g.
Code: Select all
<html><body>
<table>
<?php
$arr = array_map('sqrt', range(0,10));
foreach($arr as $num=>$sqrt)
{
?>
<tr>
<td><?php echo $num; ?></td>
<td><?php echo $sqrt; ?></td>
</tr>
<?php
}
?>
</table>
</body></html>You can also use...
instead of...
Which is useful if you have a small piece of PHP output and a buttload of HTML.
Code: Select all
<?=$num?>Code: Select all
<? echo $code; ?>- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Don't forget that you must have short tags enabled to use this method - this can be disabled.DeGauss wrote:You can also use...
instead of...Code: Select all
<?=$num?>
Which is useful if you have a small piece of PHP output and a buttload of HTML.Code: Select all
<? echo $code; ?>
Mac