重要なお知らせ

「教えて! goo」は2025年9月17日(水)をもちまして、サービスを終了いたします。詳細はこちら>

【GOLF me!】初月無料お試し

https://oshiete.goo.ne.jp/qa/9757219.html
 以下のプログラムはHTMLとPHPが混同して学習しずらいです。
以上のURLから以前、HTMLとPHPを分けて組んでいただきました。
 自力で試みましたが、print <<<eofにするのも完璧にできませんでした、
URLのプログラムは同サイトで組んでいただきました。
HTMLとPHPを分けてプログラミングをしていただけないでしょうか?
よろしくお願いいたします。


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

<?php

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

?>

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

<?php

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

?>

</table>

<?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;}
}
?>

</body>
</html>

A 回答 (1件)

>HTMLとPHPを分けてプログラミングをしていただけないでしょうか?


質問というより、作業依頼ですよね。

依頼先を検討されるのが良いかと思います。

ここは、あなたの質問と回答を “誰か” と結びつける、日本最大級の無料Q&Aコミュニティサイトです。
    • good
    • 1
この回答へのお礼

趣味ですよ^^

お礼日時:2017/10/07 20:05

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