AdrianDevera AdrianDevera - 8 months ago 56
HTML Question

Calling PHP function in HTML

Im new to Php. Im sure this is a simple issue. I am trying to call the function getDateExpected within the tags of my html file. Id like for it to return the number as a text like below. How is this done? I see that the php script would be run using some event like a button clicked but in this case nothing is being clicked. The page is only loaded. Im aware of javascript using { } but is this possible for php or is it only meant to handle requests from a form?

//include "landing.php";
function getDateExpected($desired){
$date = date ("d");
if($date << $desired){
echo $desired - $date;
echo $date-$desired;


<!DOCTYPE html>
<title>Coming Soon</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="">
<link rel="stylesheet" href="">
body,h1 {font-family: "Raleway", sans-serif}
body, html {height: 100%}
.bgimg {
background-image: url('obg.png');
min-height: 100%;
background-position: center;
background-size: cover;

<div class="bgimg w3-display-container w3-animate-opacity w3-text-white">
<div class="w3-display-topleft w3-padding-large w3-xlarge">
<div class="w3-display-middle">
<h1 class="w3-jumbo w3-animate-top">COMING SOON</h1>
<hr class="w3-border-grey" style="margin:auto;width:40%">
<p class="w3-large w3-center">getDateExpected(21) days left</p>
<div class="w3-display-bottomleft w3-padding-large">
<a href="" target="_blank">Adrian</a>


Answer Source

As Fred-ii- commented you need PHP tags change this

<p class="w3-large w3-center">getDateExpected(21) days left</p>

to this

<p class="w3-large w3-center"><?php getDateExpected(21);?> days left</p>

And change this

  if($date << $desired)

to this

if($date < $desired)