Code University

      "Where tuition is free!"

News | Images | Contact     
  • Home
  • Coding KC
  • Scripts
  • Software
  • Templates
  • Tutorials
  • About
 

Coding Knowledge Center

PHP


Page Contents
[X] CLOSE

Conditional

  • Conditional (if/else if/else)
  • Conditional (switch)

Configuration

  • Configuration (ini_set)

Constants

  • Constants (define - case insensitive)
  • Constants (define)
  • Constants (pre-defined)

Loop

  • Loop (break)
  • Loop (do/while)
  • Loop (for)
  • Loop (while)

Strings

  • Strings (formatting - dollar amount)
  • Strings (fputcsv)

Variables

  • Variables (casting)
  • Variables (set)
  • Variables (superglobals)
  • Variables (types)
  • Variables (variable functions)
Toggle Page Contents
Conditional (if/else if/else)Copy  To New Window  Top ^
if () { } else if () { } else { }
If/else if/else construct.



Conditional (switch)Copy  To New Window  Top ^
switch () { case test1: break; case test2: break; case test3: break; default: break; }
Switch construct.



Configuration (ini_set)Copy  To New Window  Top ^
ini_set("session.save_path", "C:\\Windows\\Temp\\dev.mysite.com");
Sets the path session data will be written to. When dealing with multiple sub-domains, I've had to do this to avoid session_start() permission write errors.



Constants (define - case insensitive)Copy  To New Window  Top ^
define("PI", 3.14, true); echo "PI equals " . pi;
Set constant variable named 'PI' to 3.14 but in this case the variable name is not case sensitive.



Constants (define)Copy  To New Window  Top ^
define("PI", 3.14); echo "PI equals " . PI;
Set constant variable named 'PI' to 3.14.



Constants (pre-defined)Copy  To New Window  Top ^
1) __FILE__ 2) __LINE__ 3) PHP_VERSION
1) File php is currently reading. 2) Current line number php is reading from file. 3) Version of php running.



Loop (break)Copy  To New Window  Top ^
break - ends loops continue - ends iterations
Different ways to end loops.



Loop (do/while)Copy  To New Window  Top ^
do { } while (condition);
Do/while loop construct.



Loop (for)Copy  To New Window  Top ^
for (ini; condition; mod) { }
For loop construct.



Loop (while)Copy  To New Window  Top ^
while (condition) { }
While loop construct.



Strings (formatting - dollar amount)Copy  To New Window  Top ^
$initial_amount = number_format($Tarray[5],2,.,,);
Formats a number into a dollar amount.



Strings (fputcsv)Copy  To New Window  Top ^
fputcsv($out, array($ein,$aba,$trustname,$ktid,$dateTrust,$initial_amount,$trustee_name));
Takes an array and combines each element into a csv string.



Variables (casting)Copy  To New Window  Top ^
$newvar = (integer) $orgvar
This is called casting. It produces a copy of $orgvar leaving the original $orgvar untouched. Here we are creating an integer version of the original variable.



Variables (set)Copy  To New Window  Top ^
$var = 1;
Set variable named 'var' to a value of 1.



Variables (superglobals)Copy  To New Window  Top ^
$_GET - variables provided using GET method $_POST - variables provided using POST method $_COOKIE - variables provided using cookies $_FILES - variables provided using uploads $_SERVER - info such as headers, file paths and script locations $_ENV - variables provided as server environment $_REQUEST - variables provided through user input $_SESSION - variables currently registered in a session
These are all superglobals provided by php.



Variables (types)Copy  To New Window  Top ^
boolean true/false integer - whole number floar or double - floating point number string - character collection object - instance of a class array - ordered set of keys/values resource - database NULL - uninitialized variable value
These are the various variable types.



Variables (variable functions)Copy  To New Window  Top ^
gettype($var) - get variable type settype($var) - set variable type
These are self explanatory.
Technologies
  • Introduction
  • Awk
  • Bash
  • Cron
  • CSH
  • CSS
  • CVS
  • FTP
  • FTPS
  • HTML
  • JavaScript
  • KSH
  • Linux
  • Linux (Debian)
  • Linux (LPIC 101-102)
  • Linux/Unix
  • Mac OS X
  • MySQL
  • Oracle
  • Perl
  • PGP
  • PHP
  • Sed
  • SQLite
  • SSH/SCP/SFTP
  • Telnet
  • UNIX
  • Windows
Resources
  • CodeIgniter - MVC Framework
  • HowtoForge - Linux Tutorials
  • Linux Today - Linux News
  • Lxer - Linux News Feed
  • Monsterb - Linux, Podcasting
  • MySQL - Databasing
  • Perl - Programming
  • PHP - Programming
  • Systhread - Admin & Programming
  • W3Schools - Web Tutorials
About

Code University contains a wealth of technical information aimed at the computer sciences.


 
Home | Coding KC | Scripts | Software | Templates | Tutorials | About
Top ^
 
© 2007-2012 Code University| Disclaimer
Website template by Arcsin