I have a declared html file which is then used as an include statement inside a php file.
<?php
$social_width = "50";
$social_height = "50";
?>
and
<a href="https://www.instagram.com"><img src="instagram.png" width="<?php echo $social_width; ?>" height="<?php echo $social_height; ?>" style="padding-left:400px;"></a>
When I debug, that is to say, echo out the variables they do have the right set values. I tried using single and double quotes, escaping quotes but did not find the solution yet.
My Answer:
To output PHP variables inside HTML elements as values, you can use the following syntax:
html
Outputting PHP Variables
Welcome,
Your email address is:
In your PHP file, you can define the variables `$username` and `$email` before including the HTML file:
php
$username = "John Doe";
$email = "[email protected]";
?>
When the PHP file is executed, the HTML file will be included and the PHP variables will be outputted inside the HTML elements as values.
Rate this post
3 of 5 based on 1247 votesComments