0
Unable to use HTLM tags in my pho code
Hello I need someone to help me here. I use sublime text as my editor and use it to build my HTLM and php codes. When I write html or css code it works fine. When I write php codes as well, am able to build it and it works fine also. But when I use HTLM tags like <p> or <br> etc it doesn’t work fine, instead it see the html tags as strings and prints them in the output. I need to know what am doing wrong. Thanks
13 odpowiedzi
0
You can't simply mix html (that's not a language) and PHP (that must be compiled) in an html file. PHP can be used to generate html that your Browser interprets. But it has no glue what to do with PHP.
+ 2
Do you want us to diagnose without seeing the patient?😂
Give us the code and we'll see how to cure it.☺
0
<?php
$Num1 = 40;
$Num2 = 50;
echo "$Num1 <br>";
echo "$Num2";
?>
0
this is a sample code ... very basic .. the output i get is 40 <br> 50 instead of 40 and 50 on the next line
0
Cause your result is not valid html missing HTML tags, and a Body (and a HTML Header).
0
<!DOCTYPE html>
<html>
<head>
<title>Test1</title>
</head>
<body>
<?php
$Num1 = 40;
$Num2 = 50;
echo "$Num1 <br>";
echo "$Num2";
?>
</body>
</html>
0
even with this Daniel i get the same result ...
0
<!DOCTYPE html>
<html>
<head>
<title>Test1</title>
</head>
<body>
40 <br>50</body>
</html>
[Finished in 0.1s]
0
this is the result i get . i am using sublime text editor
0
Your are writing with echo to an Output Stream of your Browser, not the DOM of your Webpage.
0
thanks man appreciate the insight . i finally got it to work! worked as expected on the browser
0
Please share the solution, so everyone can learn from it.
0
simply copied my .php file to the HTDOCS folder of my server and then opened the file from the webpage using localhost.filename.php