Php Cheat Sheet

ADVERTISEMENT

PHP Cheat Sheet
PHP Syntax
PHP Conditions &
Functions
File Functions
Loops
  Opening/Closing Tags: <?php   ?>
  time(); // Current Unix Timestamp
  fopen(filename, method);
  Instruction Termination: ;
  date(); // Formats Date/Time
  feof(filehandle);
  if (condition) { action }
  Comments: /*   */   or   //   or   #
  strtotime(); // Parses to Timestamp
  fgets(filehandle);
  elseif (condition) { action }
  include("");
  filesize(filename);
  else { action }
  require("");
  fread(filehandle, filesize);
PHP Variables
  mail(to,subject,message);
  fwrite(filehandle, filedata);
  switch (1st half of condition) {
  fclose(filehandle)
    case "2nd half of condition":
  unlink(filename);
User-Defined Functions
  $example_1 = 789;
    action
  $example_2 = 'value';
    break;
GD Library Image
  $example_3 = "value"; 
  default:
  function name() { }
    action
Functions
  name();
PHP Echo
    break;
  }
Predefined Variables
  header()
  echo 'string';
  while (condition) {
  imagecreate()
  echo "string";
    action
  imagecreatetruecolor()
  echo $variable; 
    increment condition variable
  $_GET
  imagecolorallocate()
  }
  $_POST
  imagefilltoborder()
  $_FILES
PHP Strings
  imagejpeg(), imagegif(), imagepng()
  do {
  $_SERVER
  imagedestroy()
    action
  $_COOKIE
  imagecreatefromgif()
    increment condition variable
  $_SESSION
  Escape Character: \
  imagecreatefromjpeg()
  }
  $_REQUEST
  Concatenation Operator: .
  imagecreatefrompng()
  while (condition);
  $GLOBALS
  Concatenation Assignment: .=
  imagettftext()
  $php_errormsg
  imagefilter()
  for (initialize; condition; increment)
  imagecopyresampled()
PHP Operators
  { action to take }
Browser Interaction
PHP Arrays
    Assignment: =
  session_start();
    Arithmetic: +   -   *   /   %
  session_destroy();
    Inc./Dec.: ++   --
  array("value0", "value1");
  setcookie(name, value, expiration);
    Logical: &&   ||   !
  array("key0" => "value0");
    Comparison:
  foreach (array as value) { action }
        ==   !=   <>   >   <   >=   <=

ADVERTISEMENT

00 votes

Related Articles

Related forms

Related Categories

Parent category: Education
Go