+ 3

Can i use PHP with HTML? and Where can use PHP in <body> and <head>?

7th Apr 2018, 2:15 PM
Sarmad Saad
Sarmad Saad - avatar
6 Réponses
+ 5
yes
7th Apr 2018, 2:18 PM
Toni Isotalo
Toni Isotalo - avatar
+ 5
You can use it anywhere you want <head> <base href=<?php echo "http://" . $_SERVER["HTTP_HOST"] ?>> </head>
7th Apr 2018, 2:25 PM
Toni Isotalo
Toni Isotalo - avatar
+ 5
No because the output would be <head> hello </head> And that's not what head tag is used for
7th Apr 2018, 2:30 PM
Toni Isotalo
Toni Isotalo - avatar
+ 4
<body> <?php if(isset($_SESSION["login"])) { <p> Logged in as <?php echo $_SESSION["login"]["name"]; ?> </p> <?php } ?> </body>
7th Apr 2018, 2:27 PM
Toni Isotalo
Toni Isotalo - avatar
+ 2
But can use? <head> <?php echo "hello" ; ?> </head>
7th Apr 2018, 2:28 PM
Sarmad Saad
Sarmad Saad - avatar
+ 2
Thanks for answers
7th Apr 2018, 2:35 PM
Sarmad Saad
Sarmad Saad - avatar