Table of Contents

PHP Notes

PHP Cheat Sheet

Following is basic PHP language info, to refresh my memory.

Syntax

Relational Operators

Variables

If Else

   if (condition 1) {
      statement 1; }
   elseif (condition 2) {
      statement 2; }
   else {
      statement 3; }

For Loop

Like Java

   for (<intialize>;<condition>;<update>) {
      statements;
   }

Unlike Java - foreach

  foreach ($arrayname as $arrayitem) {
      statements;
      break;
      continue;
   }
   foreach ($arrayname as $key => $value) {
       statements;
   }

Common Functions

User-Defined Functions

   function myFunction ($myparam = "default value") {
 
      return "I'm done.";
   }

Class structure

   class MyClass {
 
      public $myTitle = "hello";
      public function myFunction($myparameter = "default value") {
      }
 
   }

Declare and Use Class