🟢 Foundation · Lesson 03
PHP Syntax and Echo
PHP Syntax and Echo
PHP Syntax Basics
PHP code lives between
<?php and ?> tags. It can be mixed inside HTML. Every statement ends with a semicolon ;.echo and print
<?php
echo "Hello, World!";
echo "<br>";
print "This also prints";
?>Hello, World!
This also prints
Mixing PHP with HTML
<h1>My Page</h1>
<?php
$name = "Aman";
echo "<p>Welcome, $name</p>";
?>My Page
Welcome, Aman
Comments
// single line comment
# also single line
/* multi-line
comment */
Summary
- PHP code goes between
<?php ?>; statements end with;. echoandprintoutput text; can mix with HTML.
PHP Syntax की मूल बातें
PHP code
<?php और ?> tags के बीच रहता है। इसे HTML के अंदर मिला सकते हैं। हर statement semicolon ; से खत्म होती है।echo और print
<?php
echo "Hello, World!";
echo "<br>";
print "This also prints";
?>Hello, World!
This also prints
PHP को HTML के साथ मिलाना
<h1>My Page</h1>
<?php
$name = "Aman";
echo "<p>Welcome, $name</p>";
?>My Page
Welcome, Aman
Comments
// single line comment
# also single line
/* multi-line
comment */
सारांश
- PHP code
<?php ?>के बीच; statements;से खत्म। echoऔरprinttext दिखाते हैं; HTML के साथ मिला सकते हैं।