Are you first timer at lazacode.org? Why not join us and start exchange your knowledge with everyone. Register today!

PHP 5 - Syntax

0 votes
17 views
added Mar 15 in PHP by Callum Sergeant (1,430 points)
edited Mar 21 by LC Marshal

Comment multiple PHP lines

<?php /***?>
<div class="input checkbox m-reset">
  <input type="checkbox" id="saved-<?php echo $item['nid']; ?>">
  <label for="saved-<?php echo $item['nid']; ?>" class="p-reset"></label>
</div> 
/****/ ?>

3 Responses

0 votes
responded Apr 24 by LC Marshal First Warrant Officer (9,130 points)

PHP statements end with a semicolon (;).

<?php
echo "Hello Lazacode!";
?>
0 votes
responded Apr 24 by LC Marshal First Warrant Officer (9,130 points)

Case-sensitive are not applicable to all PHP keywords (i.e if, else, while, echo, etc.), classes, functions, and user-defined functions.

<?php
ECHO "Hello Lazacode!<br>";
echo "Hello Lazacode!<br>";
EcHo "Hello Lazacode!<br>";
?>

 

However; all variable names are case-sensitive. The following example of variables treated as 3 different variables.

<?php
$color = "brown";
$COLOR = "black";
$coLOR = "white";
echo "My hair color is " . $color . "<br>";
echo "My motorbike color is " . $COLOR . "<br>";
echo "My house color is " . $coLOR . "<br>";
?>
0 votes
responded May 22 by LC Marshal First Warrant Officer (9,130 points)

PHP Comment multi lines 

<?php /**********
    <?php if($proGroup) : ?>
      <div class="block-content">
        <h2><?php print $totalProj ?> Project<?php echo ($totalProj != '1')?'s':'';?>/Township<?php echo ($totalProj != '1')?'s':'';?>
            (<?php print $totalTras; ?> Transaction<?php echo ($totalTras != '1')?'s':'';?>)</h2>
      </div>
    <?php else: ?>
      <div class="block-content">
        <h2><?php print "$totalTras {$summary['duration']}"; ?></h2>
      </div>
    <?php endif;?>
    ********/?>
lazacode.org - Malaysia based Knowledge Exchange Platform, where you can share your finding or solution with other members of community.
...