Archive:PHP and MySQL Programming/Syntax Overview: Difference between revisions

wikademia>Kencyber
wikademia>Wikademia
 
(9 intermediate revisions by 4 users not shown)
Line 1: Line 1:
== PHP tags: ==
== PHP tags: ==
 
{{ntnes}}
=== '''<?php [code] ?>''' ===
=== '''<?php [code] ?>''' ===


Line 45: Line 45:


Which will output something like ''2005-11-09 19:40:05''.
Which will output something like ''2005-11-09 19:40:05''.
[[]]


== Commenting ==
== Commenting ==
Line 54: Line 55:
* Example:
* Example:
<source lang="php">
<source lang="php">
  echo “Hello”; # Everything from the hash is commented out
  echo "Hello"; # Everything from the hash is commented out
</source>
</source>


Line 186: Line 187:
* Example:
* Example:
<source lang="php">
<source lang="php">
$a = “Fill the halls “;
$a = "Fill the halls ";


$b = “with poisoned ivy...“;
$b = "with poisoned ivy...";


$c = $a . $b;  # the '.' operator concatenates two variables.
$c = $a . $b;  # the '.' operator concatenates two variables.


// $c = “Fill the halls with poisoned ivy...”
// $c = "Fill the halls with poisoned ivy...";
</source>
</source>


Line 211: Line 212:
// $a[3] = 4;
// $a[3] = 4;


$b = array(“name” => ”Fred”, “age” => 30);
$b = array("name" => "Fred", "age" => 30);


// $b['name'] = “Fred”;
// $b['name'] = "Fred";


// $b['age'] = 30;
// $b['age'] = 30;
Line 349: Line 350:
      
      
     function who_am_i() {
     function who_am_i() {
       echo "My name is {$this->name), and I am a dog";
       echo "My name is {$this->name}, and I am a dog";
     }
     }
  }
  }