電子書籍の厳選無料作品が豊富!

http://afurieitohannei.la.coocan.jp/phphtml.png
以上URLですが、表内から文字がはみ出てしまいます。
 はみ出た文字を表の二行目に入れたいのですがどうしたらできますか?
よろしくお願いいたします。
<?php

class person
{
protected $name = "姓名";
protected $age = 20;

public function __construct($nm,$ag)
{
$this->name = $nm;
if($ag>=20 && $ag<=60){
$this->age = $ag;
}
else
$this->age = -1;
}
public function getname(){return $this->name;}
public function getage(){return $this->age;}
}

class User extends person
{
private $adr = "xxx@xxx.xx.xx";
private $tel = "xx-xx-xxxx";

public function __construct($nm,$ag,$ad,$tl)
{
parent::__construct($nm,$ag);
$this->adr = $ad;
$this->tel = $tl;
}
public function getname(){return"会員:" . $this->name;}
public function getadr(){return $this->adr;}
public function gettel(){return $this->tel;}
}

$usr1 = new User("鈴木",56, "mmm@nnn.nn.jp", "03-xxx-xxx");

print <<<eof
<tr>
<td>{$usr1->getname()}</td>
<td>{$usr1->getage()}</td>
<td>{$usr1->getadr()}</td>
<td>{$usr1->gettel()}</td>
<tr>


<!DCTYPE html>
<html>
<head>
<title>派生クラス継承とオーバーライトPhp Html</title>
</head>
<body>



<table border="2">
<tr bgcolor="#AAAAAA">
<th>名前</th>
<th>年齢</th>
<th>アドレス</th>
<th>電話</th>
</tr>

</table>

</body>
</html>
eof;
?>

質問者からの補足コメント

  • どう思う?

    以下ではダメでした。
    <!DCTYPE html>
    <html>
    <head>
    <title>派生クラス継承とオーバーライトPhp Html</title>
    </head>
    <body>
    <tr>
    <td><?php echo $usr1->getname(); ?></td>
    <td><?php echo $usr1->getage(); ?></td>
    <td><?php echo $usr1->getadr(); ?></td>
    <td><?php echo $usr1->gettel(); ?></td>
    </tr>
    <table border="2">
    <tr bgcolor="#AAAAAA">
    <th>名前</th>
    <th>年齢</th>
    <th>アドレス</th>
    <th>電話</th>
    </tr>

    </table>

    </body>
    </html>
    eof;
    ?>

    No.2の回答に寄せられた補足コメントです。 補足日時:2017/10/14 19:02

A 回答 (2件)

<?php


// 処理
?>
<!DCTYPE html>
<html>
...
<table>
<thead> ... </thead>
<tbody>
<tr>
<td><?php echo $usr1->getname(); ?></td>
<td><?php echo $usr1->getage(); ?></td>
<td><?php echo $usr1->getadr(); ?></td>
<td><?php echo $usr1->gettel(); ?></td>
</tr>
</tbody>
</table>
...
この回答への補足あり
    • good
    • 1
この回答へのお礼

ごかいとうくださいましてありがとうございました。
手がいあたら試してみます。
しばらくお待ちくださいませ

お礼日時:2017/10/13 19:41

tableタグの中でtrの追加について表記してみては?

    • good
    • 0
この回答へのお礼

ご回答くださいましてありがとうございました。

 確かにhtml内で表にすることは、王道かもしれません!

「以下のURLを参考にしての質問」とすればよかったのですが悪しからず。
以下のプログラムはPHP内プログラムの所掌である表プログラムと、html内のプログラムの所掌である表のプログラムは分けてプログラムされています。そして、プログラムはPHPとHTMLを完全に分けてありますのでプログラム的に理解しやすかったので興味を持ちました。以下URLを参考にして私なり組み込みましたが!できなかったので質問をしました。

 
https://oshiete.goo.ne.jp/qa/9757219.html
を参考に、作成しましたが!

 webプログラムの肝はプログラムとデザインをわけることです。
HTMLの表示はデザイナーさんが適宜調整をしてくれるものなので
プログラマは動的な部分をいかに効率よく渡してやるかだけ考えればいいでしょう

お礼日時:2017/10/21 06:59

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!