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

9th May 2019, 8:17 AM
Ralph
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.
9th May 2019, 11:07 AM
Daniel Adam
Daniel Adam - avatar
+ 2
Do you want us to diagnose without seeing the patient?😂 Give us the code and we'll see how to cure it.☺
9th May 2019, 10:43 AM
Solo
Solo - avatar
0
<?php $Num1 = 40; $Num2 = 50; echo "$Num1 <br>"; echo "$Num2"; ?>
9th May 2019, 11:13 AM
Ralph
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
9th May 2019, 11:15 AM
Ralph
0
Cause your result is not valid html missing HTML tags, and a Body (and a HTML Header).
9th May 2019, 11:17 AM
Daniel Adam
Daniel Adam - avatar
0
<!DOCTYPE html> <html> <head> <title>Test1</title> </head> <body> <?php $Num1 = 40; $Num2 = 50; echo "$Num1 <br>"; echo "$Num2"; ?> </body> </html>
9th May 2019, 11:19 AM
Ralph
0
even with this Daniel i get the same result ...
9th May 2019, 11:20 AM
Ralph
0
<!DOCTYPE html> <html> <head> <title>Test1</title> </head> <body> 40 <br>50</body> </html> [Finished in 0.1s]
9th May 2019, 11:21 AM
Ralph
0
this is the result i get . i am using sublime text editor
9th May 2019, 11:22 AM
Ralph
0
Your are writing with echo to an Output Stream of your Browser, not the DOM of your Webpage.
9th May 2019, 11:30 AM
Daniel Adam
Daniel Adam - avatar
0
thanks man appreciate the insight . i finally got it to work! worked as expected on the browser
9th May 2019, 12:11 PM
Ralph
0
Please share the solution, so everyone can learn from it.
9th May 2019, 12:11 PM
Daniel Adam
Daniel Adam - avatar
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
9th May 2019, 12:15 PM
Ralph