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

Encoding

FOR QUERY STRINGS
echo urlenc­ode­($s­tring);

FOR PATH STRINGS
echo rawurl­enc­ode­($s­tring);

FOR HTML CHARS (<>­&")
echo htmlsp­eci­alc­har­s($­str­ing);

FOR SPECIAL CHARS IN HTML
echo htmlen­tit­ies­($s­tring);
 

Includes

INSERTS FILE CONTENTS
includ­e("f­ile.ph­p");

ADDS FILE PATH TO ARRAY OF FILES TO INCLUDE IF NOT ALREADY INCLUDED
includ­e_o­nce­("fi­le.p­hp­");

RAISES PAGE ERROR IF FILE CANNOT BE INSERTED
requir­e("f­ile.ph­p");

ADDS FILE PATH TO ARRAY OF FILES TO REQUIRE IF NOT ALREADY REQUIRED
requir­e_o­nce­("fi­le.p­hp­");
 

Page Headers

To change a part of the page header:
header­($s­tring);

To make a header change request there must be absolutely no output prior to the request. Not even a blank line before the php.

Examples:
header­("Lo­cation: newFil­e.p­hp");

For Page Redirects
<?php

  header­("Lo­cation: newfil­e.p­hp");

  exit;

?>