Show Menu
Cheatography

PHP Basics Cheat Sheet (DRAFT) by

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Opening and Closing tags

<?php ?>
<? ?>
<script langua­ge=­"­php­"> </s­cri­pt>
<% %>

Comments

/*
Multi - line
*/

// Single Line

# Single Line

Variables and Functions

$var1 = "­Var­aible conten­t";
static $var = 5;

function fname(­$var1, $default = "­dat­a")
{
data
}
$reference = &$­ref­ere­nced;

Useful Functions

nl2br(­$var);
$is_ty­pe(­$var);
define­('N­AME', $value);
includ­e($­file); // include _once
requir­e($­file); // requir­e_once
array_­sea­rch­("se­arc­h", $arr);
trim($­var); // ltrim and rtrim
strpos­($data, $value);
substr­($var, $start, $endop­tio­nal);