Hello, Guys, Today we will see some basic concepts of Printing in PHP Programming Language. If you are already experienced in programming before, this tutorial will be a lot easier for you. For the newbies starting out in PHP, don’t worry just follow the article, try to understand syntax by rewriting codes in your own style 5 6 times. So let’s start our tutorial on HTML basics in PHP Programming.
Printing Text on Screen in PHP
<?php //Printing Basics For Everyone echo "Hello Ladies and Gentlemens"; echo "<br>";
TO print text on screen -> Simply write text in between double quotes. To use HTML tags, we enclose tags in double quotes itself. For Example- “<h1>Programminng Jesus</h1>”
Concatenation of Strings in PHP (Joining 2 Strings)
echo "<h1>Making Codes Easy</h1><br>"; echo "Joining"." Two"." Statements"; //We use . (dot) operator for concatenation. Simple use . in between two strings and it will automatically concatenate them. $age=20; echo "<br><br>"; echo $age; echo "<br>". $age . "<br>"; //Put variable and concatenate accordingly. NOTE: If You want to print out value of a variable- You can print it out by putting variable inside or outside the Double quotes.
LEARN: How to use Functions in PHP
HTML basics in PHP – Making An HTML Table using PHP
echo "<br><br>"; //Making HTML Table using php echo "<table border=1>"; // As i told you earlier, we will use html tags in echo statement using Double Quotes. echo "<tr>"; echo "<td> Column 1 </td>"; echo "<td> Column 2 </td>"; echo "</tr>"; echo "<tr>"; echo "<td> Column 3 </td>"; echo "<td> Column 4 </td>"; echo "</tr>"; echo "</table>";
Above Section of code is quite explainatory. If you have any doubt regarding the concept, open up this article. Learn: How to Create Colorful Table using HTML and PHP
HTML basics in PHP : Writing Colorful text
echo "<p style=color:red>My Name is Macky</p>"; echo "<br>"; //We can use inline CSS
Printing using for Loop
for($i=1;$i<10;$i++) echo "<p style=background-color:lightblue>".$i."</p>";
//Thou it has nothing much to do in HTML in For loop, but just for better understanding. If you have any doubt in this, please let me know via comments below. I will post a new article soon on Using Loops in PHP programming.
HTML Basics in PHP – Creating HTML Form
HTML Forms basics for PHP Programmers
Simply we are making an example HTML form. with 2 text boxes and 1 submit button.
<html> <body> <form name="frm1"> <input type="text" placeholder="Enter Your Name" name="col1"> <input type="text" placeholder="Enter Your Age" name="col"> <input type="Submit"> </form> <br><br>; </body> </html>
Final Output of All Code:
If you liked this article and learnt the HTML basics in PHP Language, please do share our article on at least one social media, We are trying hard to reach more people with our quality content, without your support we are nothing. Please do share this article and join the newsletter of Programmingy. You can check our complete PHP Programming Tutorial series.