Post: When writing a PHP file should you declare HTML content within HTML and BODY tags?
05-07-2016, 02:50 AM #1
(adsbygoogle = window.adsbygoogle || []).push({}); I've just started learning PHP and I have a question. I'm running XAMPP and just echoing a variable into a paragraph. This paragraph element still displays regardless of whether I put it inside <HTML> or <BODY> tags? In PHP do you need to declare HTML and BODY or do you just write markup wherever you like?

If this is in the wrong area I apologize
05-07-2016, 03:21 AM #2
Toxic
former staff
Originally posted by Kaptai View Post
I've just started learning PHP and I have a question. I'm running XAMPP and just echoing a variable into a paragraph. This paragraph element still displays regardless of whether I put it inside <HTML> or <BODY> tags? In PHP do you need to declare HTML and BODY or do you just write markup wherever you like?

If this is in the wrong area I apologize


Moved to programming inquires.
Do you want the echo by itself in the page? like without any html tags?
Sorry if i got you wrong, did not fully understand your question tbh :p
05-07-2016, 03:45 AM #3
Specter
Pro Memer
Originally posted by Kaptai View Post
I've just started learning PHP and I have a question. I'm running XAMPP and just echoing a variable into a paragraph. This paragraph element still displays regardless of whether I put it inside <HTML> or <BODY> tags? In PHP do you need to declare HTML and BODY or do you just write markup wherever you like?

If this is in the wrong area I apologize


Anything not enclosed within <?php and ?> tags are considered markup. See example below;

    
<?php
$age = 10;
?>

<b><?php echo $age; ?></b>


The code is kind of useless but it's an example, $age = 10 is PHP and enclosed in PHP tags. After that we're using HTML code using bold tags and echoing age in php tags again. I hope you kind of understand what I'm trying to illustrate here.

The following user thanked Specter for this useful post:

Kexploit

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo