dsn46282 2015-11-27 07:37
浏览 56
已采纳

HTML中的Php不起作用

Look, i have html with included php link but that doesn't work well.Information what was in html doesn't come to php page. Please help with that.

HTML CODE:

<!DOCTYPE html PUBLIC "-//W3C//DTD
➝ XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/
➝ DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/
➝ 1999/xhtml" xml:lang="en"
➝ lang="en">
<head>
<meta http-equiv="Content-Type"
➝ content="text/html;
➝ charset=utf-8"/>
<title>Greetings!</title>
</head>
<body>
<!-- Script 3.6 - hello.html -->
<div><p>Click a link to say
➝ hello:</p>
<ul>
<li><a href="hello.php?
name=Michael">Michael</a></li>
<li><a href="hello.php?
name=Celia">Celia</a></li>
<li><a href="hello.php?
name=Jude">Jude</a></li>
<li><a href="hello.php?
name=Sophie">Sophie</a></li>
</ul>
</div>
</body>
</html>

PHP code:

    <!DOCTYPE html PUBLIC "-//W3C//DTD
➝ XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/
➝ DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/
➝ 1999/xhtml" xml:lang="en"
➝ lang="en">
<head>
<meta http-equiv="Content-Type"
➝ content="text/html;
➝ charset=utf-8"/>
<title>Greetings!</title>
</head>
<body>
<?php // Script 3.7 - hello.php
error_reporting (E_ALL | E_STRICT);
$name - $_GET['name'];
print "<p>Hello, <span
style=\font-weight:
bold;\">$name</span>!</p>";
?>
</body>
</html>

And this how it's look on web http://santa-monica.comli.com/hello.html

http://santa-monica.comli.com/hello.php?name=Michael

  • 写回答

2条回答 默认 最新

  • drqj8605 2015-11-27 07:45
    关注

    your link to the php page is working fine, your problem is where u define the name variable, you have a typo, instead of $name = $_GET['name']; you put $name - $_GET['name'];, dont worry this happens to the best of us, fix that and it should run smoothly, btw if you are testing your php code on an online server dont, because it is slower than on your pc, unless you are contacting an api, it doesnt work unless its executing online

    EDIT :

    change your code to this :

    <?php // Script 3.7 - hello.php
    error_reporting (E_ALL | E_STRICT);
    $name = $_GET['name'];
    ?>
    <p>Hello, <span
    style=\font-weight:
    bold;\"><?php echo $name; ?></span>!</p>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度