This is a draft cheat sheet. It is a work in progress and is not finished yet.
Encoding
FOR QUERY STRINGS
echo urlencode($string);
FOR PATH STRINGS
echo rawurlencode($string);
FOR HTML CHARS (<>&")
echo htmlspecialchars($string);
FOR SPECIAL CHARS IN HTML
echo htmlentities($string); |
|
|
Includes
INSERTS FILE CONTENTS
include("file.php");
ADDS FILE PATH TO ARRAY OF FILES TO INCLUDE IF NOT ALREADY INCLUDED
include_once("file.php");
RAISES PAGE ERROR IF FILE CANNOT BE INSERTED
require("file.php");
ADDS FILE PATH TO ARRAY OF FILES TO REQUIRE IF NOT ALREADY REQUIRED
require_once("file.php"); |
|
|
Page Headers
To change a part of the page header:
header($string);
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("Location: newFile.php");
For Page Redirects
<?php
header("Location: newfile.php");
exit;
?>
|
|