How can PHP and HTML interact

The Eduladder is a community of students, teachers, and programmers just interested to make you pass any exams. So we solve previous year question papers for you.
In eduladder you can Ask,Answer,Listen,Earn and Download Questions and Question papers.
Watch related videos of your favorite subject.
Connect with students from different parts of the world.
Apply or Post Jobs, Courses ,Internships and Volunteering opportunity. For FREE
See Our team
Wondering how we keep quality?
Got unsolved questions? Ask Questions

PHP-->View question

How can PHP and HTML interact?

its about How can PHP and HTML interact


Asked On2019-09-06 15:46:36 by:Annaliya

Taged users:


Likes:
Be first to like this question

Dislikes:
Be first to dislike this question
Talk about this  Like  Dislike
View all qusetions
Answers

How can PHP and HTML interact ?

It is possible to generate HTML through PHP scripts, and it is possible to pass informations from HTML to PHP.

PHP is a server side language and HTML is a client side language so PHP executes on server side and gets its results as STRING, ARRAYs, OBJECTS or so and then we use results to display its values in HTML.

See how easy that is? Integrating PHP and HTML is really very simple. Just remember that at its core, a PHP script is just an HTML page with some PHP sprinkled through it. If you want, you can create a PHP script that only has HTML in it and no <?php ?> tags, and it will work just fine.

<html>
<head></head>
<body>
<ul>
<?php for($i=1;$i<=5;$i++){ ?>
<li>Menu Item <?php echo $i; ?></li>
<?php } ?>
</ul>
</body>
</html>

 

PHP in HTML

When building a complex page, at some point you will be faced with the need to combine PHP and HTML to achieve your needed results. At first point, this can appear to be convoluted, since PHP and HTML are two separate languages, yet this isn’t the situation. PHP is intended to communicate with HTML and PHP contents can be incorporated into a HTML page without an issue.

<html>

<head></head>
<body class=”page_bg”>
Hello, today is <?php echo date(‘l, F jS, Y’); ?>.
</body>

</html>

 

HTML in PHP

You can also use HTML code in a PHP script. This can be extremely helpful in the event that you have manufactured your entire page in PHP, however need to incorporate a custom HTML frame, for instance. That you should simply switch the request of the HTML and PHP opening tags, opening the page with PHP:

<?php
$Fname = $_POST[“Fname”];
$Lname = $_POST[“Lname”];
?>
<html>
<head>
<title>Personal INFO</title>
</head>
<body>
<form method=”post” action=”<?php echo $PHP_SELF;?>”>
First Name:<input type=”text” size=”12″ maxlength=”12″ name=”Fname”><br />
Last Name:<input type=”text” size=”12″ maxlength=”36″ name=”Lname”><br /></form>
<?
echo “Hello, “.$Fname.” “.$Lname.”.<br />”;
?>


Answerd on:2019-09-07 Answerd By:Tanisha-Garg

Likes:
Be first to like this answer

Dislikes:
Be first to dislike this answer
Talk about this  Like  Dislike

You might like this video:Uses of Javascript
Watch more here

Watch more videos from this user Here

Learn how to upload a video and start earning here



Lets together make the web is a better place

We made eduladder by keeping the ideology of building a supermarket of all the educational material available under one roof. We are doing it with the help of individual contributors like you, interns and employees. So the resources you are looking for can be easily available and accessible also with the freedom of remix reuse and reshare our content under the terms of creative commons license with attribution required close.

You can also contribute to our vision of "Helping student to pass any exams" with these.
Answer a question: You can answer the questions not yet answered in eduladder.How to answer a question
Career: Work or do your internship with us.Work with us
Create a video: You can teach anything and everything each video should be less than five minutes should cover the idea less than five min.How to upload a video on eduladder