+ 3
How to use PHP ?
I just finished the PHP Tutorial but I still can't actually use it in my Testing Website, so I need to know should I write the PHP code inside of the HTML file, or the JS file, or in a file of it's on ? if it's in a file alone how to link it with the HTML file?
6 Answers
+ 2
You write it into php file. HTML file doesn't support php but php file supports php, html, css and javascript.
index.php
<?php
/* Your php code */
?>
<html>
<head>
</head>
<body>
</body>
</html>
There you go. Start with that
+ 3
just put it in your html file but be sure to open it correctly or you will mess up your code
+ 2
Here's example
<ul class="menu menu-right">
<?php if($login == false) { ?>
<li><a href="/login">Login</a></li>
<li><a href="/register">Register</a></li>
<?php } else if($login == true) { ?>
<li><a href="/profile">Profile</a></li>
<li><a href="?logout">Logout</a></li>
<?php } ?>
</ul>
+ 1
Thanks Toni That was very helpful 👍
0
Should I write it in a specific Tag or anywhere ?
0
No. inside <?php ?> always. No html tags needed.
You can include it anywhere in your document.