PHP 5 - Syntax

0 votes
507 views
added Mar 15, 2018 in PHP by Callum Sergeant (1,440 points)
edited Jul 20, 2018 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, 2018 by LC Marshal Captain (25,790 points)
edited Jul 20, 2018 by LC Marshal
// PHP statements end with a semicolon (;).

<?php
echo "Hello Lazacode!";
?>

 

0 votes
responded Apr 24, 2018 by LC Marshal Captain (25,790 points)
edited Jul 20, 2018 by LC Marshal

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, 2018 by LC Marshal Captain (25,790 points)
edited Jul 20, 2018 by LC Marshal
// 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's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...