简体   繁体   English

MAMP-有html代码时php不起作用

[英]MAMP - php doesn't work when there is html code

Let me explain my situation. 让我解释一下我的情况。 I made a local website on Windows Using WAMP. 我在Windows上使用WAMP创建了一个本地网站。 I transfered my files to a MACBOOK, and i installed MAMP 我将文件传输到MACBOOK,并安装了MAMP

For some odd reason When i submit a login form on Wamp, it shows me Blank page. 出于某些奇怪的原因,当我在Wamp上提交登录表单时,它显示给我空白页面。 I searched the internet and i found that my login.php file has html code inside because its a template, and my mamp works only if i have only php code in the login.php file For example: 我在互联网上搜索,发现我的login.php文件内部包含html代码,因为它是模板,并且只有在login.php文件中只有php代码的情况下,mamp才能工作。例如:

THIS WAY IT WORKS: 这样工作:

<?php
 echo "Hello World";
?>

THIS DOES NOT WORK: 这不起作用:

<html>
<head>
 HTML_CODE_FOR_WEBSITE_TEMPLATE
 </head>
 </html>
 <?php
 echo "hello world";
 ?>

Somehow mamp displays blank page because it thinks the code has errors HOWEVER. 模板以某种方式显示空白页,因为它认为代码有错误。 the code is 100% working, because it works 100% on Windows 该代码可以100%运行,因为它在Windows上可以100%运行

Thanks in advance 提前致谢

Try this: 尝试这个:

<!DOCTYPE html>
<html lang="en">

<head>
    <title>HTML CODE FOR WEBSITE TEMPLATE</title>
</head>

<body>
    <?php echo "hello world"; ?>
</body>

</html>

This is HTML5. 这是HTML5。 Remember, the difference isn't between "Mac" and "PC", necessarily. 请记住,“ Mac”和“ PC”之间不一定没有区别。 It's between BROWSERS. 在浏览器之间。 So you'd want to say something like "it works on Firefox (version 26) but not Safari (version xx.xx)", etc. 因此,您想要说些类似的信息,例如“它在Firefox(版本26)上有效,但在Safari(版本xx.xx)上无效”等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM