如何使用 php 在 html 中显示 chr()
how to use php to display chr() in html
我想使用 chr 函数在代码块中显示 abc++,但我不知道如何将 chr 函数合并到这个 html 代码块中。
<?php
for ($x = 65 ; $x <= 90; $x ++){
echo "<div class='black-box'>
<div class='letter'>
chr($x); <sub class='small'>$x</sub>
</div>
</div>" ;} ?>
你可以做的是:(抱歉没有解释,时间不好)
<?php
$x=0;
$target = 5000;
echo '<table style="width:50%;"><thead><tr><td style="width:50%;">Code</td><td style="width:50%;>Character</td></tr></thead><tbody>';
while($x<$target){
echo '<tr><td>'.$x.'</td><td>'.chr($x).'</td></tr>';
}
echo '</tbody></table>';
?>
编辑
<?php
$x = 65;
$target = 90;
function displaychar($from, $to){
$string = "<table style='width:50%;'><thead><tr><td style='width:50%;'>Code</td><td style='width:50%;'>Character</td></tr></thead><tbody>";
while($from<=$to){
$string=$string. '<tr><td>'.$from.'</td><td>'.chr($from).'</td></tr>';
$from++;
}
$string=$string. '</tbody></table';
return $string;
}
echo displaychar($x, $target);
?>
您必须连接 PHP 函数或回显它才能使其工作,所以这是我的代码
<?php
for ($x = 65 ; $x <= 90; $x++) {
echo "<div class='black-box'>
<div class='letter'>";
echo chr($x);
echo "<sub class='small'>$x</sub>
</div>
</div>";
}
?>
编辑
下一个函数将输出相同的内容,但将连接到相同的 echo:
<?php
for ($x = 65 ; $x <= 90; $x++) {
echo "<div class='black-box'>
<div class='letter'>".chr($x)."<sub class='small'>$x</sub>
</div>
</div>";
}
?>
查看此处了解更多信息:PHP Echo
我想使用 chr 函数在代码块中显示 abc++,但我不知道如何将 chr 函数合并到这个 html 代码块中。
<?php
for ($x = 65 ; $x <= 90; $x ++){
echo "<div class='black-box'>
<div class='letter'>
chr($x); <sub class='small'>$x</sub>
</div>
</div>" ;} ?>
你可以做的是:(抱歉没有解释,时间不好)
<?php
$x=0;
$target = 5000;
echo '<table style="width:50%;"><thead><tr><td style="width:50%;">Code</td><td style="width:50%;>Character</td></tr></thead><tbody>';
while($x<$target){
echo '<tr><td>'.$x.'</td><td>'.chr($x).'</td></tr>';
}
echo '</tbody></table>';
?>
编辑
<?php
$x = 65;
$target = 90;
function displaychar($from, $to){
$string = "<table style='width:50%;'><thead><tr><td style='width:50%;'>Code</td><td style='width:50%;'>Character</td></tr></thead><tbody>";
while($from<=$to){
$string=$string. '<tr><td>'.$from.'</td><td>'.chr($from).'</td></tr>';
$from++;
}
$string=$string. '</tbody></table';
return $string;
}
echo displaychar($x, $target);
?>
您必须连接 PHP 函数或回显它才能使其工作,所以这是我的代码
<?php
for ($x = 65 ; $x <= 90; $x++) {
echo "<div class='black-box'>
<div class='letter'>";
echo chr($x);
echo "<sub class='small'>$x</sub>
</div>
</div>";
}
?>
编辑
下一个函数将输出相同的内容,但将连接到相同的 echo:
<?php
for ($x = 65 ; $x <= 90; $x++) {
echo "<div class='black-box'>
<div class='letter'>".chr($x)."<sub class='small'>$x</sub>
</div>
</div>";
}
?>
查看此处了解更多信息:PHP Echo