🟢 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 ;.
  • echo and print output 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 और print text दिखाते हैं; HTML के साथ मिला सकते हैं।
← Back to PHP Tutorial
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।