closure-compiler icon indicating copy to clipboard operation
closure-compiler copied to clipboard

Standard scriptlets, jo <? ... ?> syntax ka upyog

Open mudassarmuz opened this issue 10 months ago • 1 comments

Standard scriptlets, jo ... ?> syntax ka upyog karte hain, code ko execute karte hain jiske liye explicit output nahi hota hai. Lekin, jaise ki is udaaharan mein dikhaaya gaya hai, scriptlet ke andar code ke parinaam bhi HTML code content ko prabhavit kar sakte hain.

Yeh hain kuchh tarah ke code jo aap scriptlet mein upyog kar sakte hain:

Variable Assignment

<?php 
 $name = "John Doe"; 
?>
<html>
 <body>
  <h1>Hello, <?php echo $name; ?>!</h1>
 </body>
</html>

Control Structures

<?php 
 $age = 25; 
?>
<html>
 <body>
  <?php if ($age >= 18) { ?>
   <p>You are an adult!</p>
  <?php } else { ?>
   <p>You are a minor!</p>
  <?php } ?>
 </body>
</html>

Function Calls

<?php 
 function greet($name) {
  return "Hello, $name!";
 }
?>
<html>
 <body>
  <h1><?php echo greet("John Doe"); ?></h1>
 </body>
</html>

Object Manipulation

<?php 
 $person = array("name" => "John Doe", "age" => 25); 
?>
<html>
 <body>
  <h1><?php echo $person["name"]; ?></h1>
  <p>Age: <?php echo $person["age"]; ?></p>
 </body>
</Html 

mudassarmuz avatar Dec 19 '24 03:12 mudassarmuz