Fillin (hover over or click) the blanks to learn about PHP, or create your own lines

+ To generate URL-encoded query string use http_build_query
+ To replace multiple 'needles' in a 'haystack' use an array datatype as the 'needle'
+ To translate characters or replace substrings use the strtr function.
+ call a method out of the object context using the :: scope resolution operator
+ the PHP function func_num_args() will return the number of parameters passed in
+ dl ( string $library ) Loads the PHP extension, given by the parameter library, at runtime
+ To prevent form resubmission, redirect the page (to itself) after submission
+ variables_order php.ini directive sets the order of the EGPCS (Environment, Get, Post, Cookie, and Server) variable parsing.
+ set_error_handler — Sets a user-defined error handler function ()
+ PATH_SEPARATOR and DIRECTORY_ SEPARATOR are predefined PHP constants
+ echo ~4; // outputs -5
+ The "interface" is a method of enforcing that anyone who implements it must include all the functions declared in the interface.
+ In PHP, concatenation is faster than variable substitution
+ An interface simply lists (function prototype) the methods a class must implement
+ var_dump('10' == 10); // returns bool(true)
+ When using ini_set('include_path',ini_get('include_path').PATH_SEPARATOR.'../includes;'); the PATH_SEPERATOR is a : in Linux and a ; in Windows
+ To view installed Apache modules on Windows do phpinfo(INFO_MODULES);
+ to execute a url from the server using PHP as an alternative to Curl, can use exec(wget $url) or fopen($url, "r") or file_get_contents($url);
+ Helpers are to views, what components are to controllers.
+ Add ?=PHPE9568F36-D428-11d2-A769-00AA001ACF42 to most sites running PHP and you will see the PHP easter egg
+ To sort multiple or multi-dimensional arrays use the PHP array_multisort function
+ Use $this to refer to the current object. Use self to refer to the current class.
+ Use $this->member for non-static members, use self::$member for static members.
+ Keep database connection file outside of the web root
+ To convert a time represented as a string to a Unix timestamp use the strtotime function
+ List files and directories inside the specified path using the scandir PHP function
+ The scope for PHP class methods can be defined as public, private or protected.
+ echo 12 ^ 9; outputs 5
+ The PHP unlink function deletes a file
+ mysql_free_result() only needs to be called if you are concerned about how much memory is being used for queries that return large result sets.
+ empty() only checks variables as anything else will result in a parse error.
+ To output a json string as comma dilimited string using PHP: echo implode(', ', (array)json_decode($json_string)
+ var_dump(0 == 'b'); // returns bool(true);
+ function testfunc($a, $b, $c){ echo func_num_args(); } testfunc(1,2,3,4); // returns 4
+ To see if a PHP variable has been set to something, even to an empty string, use isset()
+ The ReflectionMethod class reports information about the methods of a class.
+ The ReflectionProperty class reports information about the properties of a class.
+ $name = "Fred"; unset($name); // $name is NULL
+ Memcache module provides handy procedural and object oriented interface to memcached.
+ memcached is a highly effective caching daemon, which was especially designed to decrease database load in dynamic web applications.
+ Superglobals are built-in variables that are always available in all scopes
+ __call() is triggered when invoking inaccessible methods in an object context
+ __callStatic() is triggered when invoking inaccessible methods in a static context
+ realpath — Returns canonicalized absolute pathname
+ curl_exec Returns TRUE on success or FALSE on failure. However, if the CURLOPT_RETURNTRANSFER option is set, it will return the result on success, FALSE on failure
+ Never show pages in response to POST. Navigate from POST to GET using REDIRECT. Always load pages using GET.
+ get_magic_quotes_gpc — Gets the current configuration setting of magic quotes gpc
+ With register_long_arrays=Off the $GLOBALS array will not contain [_SERVER] and [_REQUEST]. They are accessible as superglobals ($_SERVER, $_REQUEST), but they disappear from the $GLOBALS array.
+ $GLOBALS — References all variables available in the global scope.
+ $_FILES is an associative superglobal array of items uploaded to the current script via the HTTP POST method.
+ get_headers — Fetches all the headers sent by the server in response to a HTTP request
+ addslashes — Returns a string with backslashes before characters that need to be quoted in database queries etc.
+ __call() is PHP's magic method for method overloading
+ Can you get all dynamic text on a page, as added by JavaScript run by the browser, using CURL? No
+ Exporting in Subversion is useful if you want to get a particular framework revision without the .svn directories.
+ The IP address from which the user is viewing the current page can be found using $_SERVER['REMOTE_ADDR']
+ Make sure library and application folders are outside web root.
+ __callStatic() is triggered when invoking inaccessible methods in a static context.
+ It is easier to distinguish view templates from other PHP files if you use a diffent file extension
+ session_set_cookie_params() would need to be called on every page, so a better solution might be to edit the php.ini file.
+ A static variable has a local scope and retains its most recent value until the next execution of this block.
+ Static variables are contrasted to automatic variables whose storage is allocated and deallocated on the call stack; and to objects whose storage is dynamically allocated.
+ The Scope Resolution Operator is a token that allows access to static, constant, and overridden properties or methods of a class.
+ Static variable lifetime extends across the entire run of the program.
+ The pseudo-variable $this is not available inside methods declared as static.
+ To assign values to static variables you need to use scope resolution operator(::) along with the class name.
+ If today is March 2 and do PHP command "echo date('d') -3" the output will be -1
+ In JavaScript the instruction document.cookie = "temperature=20" creates a cookie of name temperature and value 20
+ Components are packages of logic that are shared between controllers.
+ If you add a string to an integer using the + operator,  the string is converted to a number and added to the integer.
+ Streams can be read from or written to in a linear fashion.
+ Private class members are preceded by a single underscore.
+ The PHP compact() function creates an array containing variables and their values.
+ You can use PHP interactively at the command prompt using the -a flag
+ In PHP 5, the COM extension throws com_exception exceptions, which you can catch and then inspect the code member to determine what to do next.
+ Beside the name/value pair, a cookie may also contain an expiration date, a path, a domain name, and whether the cookie is intended only for encrypted connections.
+ strtok() splits a string (str ) into smaller strings (tokens).
+ A third optional parameter to define() is a bool field case_insensitive.
+ strip_tags() tries to return a string with all HTML and PHP tags stripped from a given str .
+ php://stdin, php://stdout and php://stderr allow direct access to the corresponding input or output stream of the PHP process.
+ php://output allows you to write to the output buffer mechanism in the same way as print() and echo().
+ php://input allows you to read raw POST data.
+ php://stdin and php://input are read-only, whereas php://stdout, php://stderr and php://output are write-only.
+ A stream is referenced as: scheme://target
+ A wrapper is additional code which tells the stream how to handle specific protocols/encodings.
+ stdClass is a skeleton class, a blank canvas if you like.
+ json_decode takes a second optional argument that when set to TRUE, will convert returned objects into associative arrays.
+ As long as included/required file is in one of the include_path folders, it will be included
+ To escape individual arguments to shell functions coming from user input, use escapeshellarg()
+ If you would like to return the output of print_r() rather than print it, set the optional second parameter to TRUE.
+ The 'final' keyword restricts overriding by child class
+ To reliably work with paths relative to the current file, use __DIR__
+ All methods declared in an interface must be public, this is the nature of an interface.
+ PHP's interpretation of "overloading" is different than most object oriented languages.
+ __set() is run when writing data to inaccessible properties.
+ At end of eval function content remember to put a semicolon
+ PHP supports one execution operator: backticks (``).
+ Overloading in PHP provides means to dynamically "create" properties and methods. 
+ PHP's interpretation of "overloading" is different than most object oriented languages.
+ array_flip — Exchanges all keys with their associated values in an array  
+ For binary safe case-insensitive string comparison use the strcasecmp() function
+ The strtr() function translates certain characters in a string.
+ The str_pad function can be used to pad a string to a minimum specific length.
+ file_put_contents() is identical to calling fopen(), fwrite() and fclose() successively to write data to a file.
+ file —Reads an entire file into an array.
+ Unix based systems use \n as the line ending character, Windows based systems use \r\n as the line ending characters and Macintosh based systems use \r as the line ending character.
+ escapeshellcmd() should be used to make sure that any data coming from user input is escaped before this data is passed to the exec() or system() functions, or to the backtick operator.
+ key() returns the index element of the current array position.
+ Namespaces are available in PHP as of PHP 5.3.0.
+ Namespaces are declared using the namespace keyword.
+ The only code construct allowed before a namespace declaration is the declare statement, for defining encoding of a source file.
+ Unlike any other PHP construct, the same namespace may be defined in multiple files, allowing splitting up of a namespace's contents across the filesystem.
+ namespace MyProject; echo '"', __NAMESPACE__, '"'; // outputs "MyProject"
+ $f = \fopen(...); // calls global fopen
+ use blah\blah as mine; // see "Using namespaces: importing/aliasing"
+ namespace MyProject; namespace\blah\mine(); // calls function MyProject\blah\mine()
+ To execute a PHP command directly from command line use the -r flag .. e.g.  php -r 'phpinfo();'
+ Declaring class members or methods as static, makes them callable from outside the object context.
+ var_export — Outputs or returns a parsable string representation of a variable
+ simplexml_load_string — Interprets a string of XML into an object
+ func_get_args — Returns an array comprising a function's argument list
+ The file() function returns the file in an array. Each element of the array corresponds to a line in the file, with the newline still attached.
+ The file_put_contents function is identical to calling fopen(), fwrite() and fclose() successively.
+ fputs is an alias of fwrite()
+ Open a persistent connection to a MySQL server using the function mysql_pconnect
+ php_uname returns information about the operating system PHP is running on
+ ?> should be used at end of php page? no
+ The 9 superglobals are: $GLOBALS $_SERVER $_GET $_POST $_FILES $_COOKIE $_SESSION $_REQUEST $_ENV
+ The two primary features of PHPMailer are sending HTML email and emails with attachments
+ The Host name from which the user is viewing the current page can be found using $_SERVER['REMOTE_HOST']
+ Use checkdate() to validate dates
+ fpassthru() can be used to send binary data from a program to the browser
+ Superglobals are built-in variables that are always available in all scopes
+ Abstract classes can be instantiated? No
+ mysql_escape_string() == mysql_real_escape_string() but the latter takes a connection handler and uses current character set
+ echo 010; outputs 8
+ NULL is considered boolean FALSE
+ $a = array( a => 'rock', b => 'paper', c => 'scissors' ); unset( $a[b] ); $a[a] == rock $a[b] == NULL $a[c] == scissors
+ If register_globals is enabled, PHP creates variables in the global scope for any value passed in GET, POST or COOKIE
+ PHPMailer is a PHP class that provides a package of functions to send email.
+ printf allows formatted output
+ PHP session behavior is controlled by configurations options in the php.ini file.
+ The default value for the register_globals directive (since 4.2.0) is off, and it is completely removed as of PHP 6
+ To send a GET request from the server use the PHP curl function
+ The regular expression to match ^ at beginning of a line is ^\^
+ PHP application input is to browser and output is to database
+ -1 is considered boolean TRUE, like any other non-zero (whether negative or positive) number
+ If you want to register a session variable from within a function, use the special $_SESSION array
+ Functions that do not explicitly return a value, return NULL
+ printf is a function, not a construct, so parentheses are required.
+ Scaffolding automatically generates a CRUD interface for a table
+ Abstract methods are placeholder methods with no implementation.
+ To swap two values elegantly: list($biggest, $smallest) = array($smallest, $biggest);
+ 'Private' limits visibility to the class that defines the item.
+ 'Protected' limits visibility to the originating and child classes
+ session_register function has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 6.0.0. Do not use.
+ Instance methods are associated with a particular object
+ Static methods are associated with a class
+ Abstract methods are used for defining a framework and are made to be overwritten
+ A nowdoc is specified similarly to a heredoc, but no parsing is done inside a nowdoc.
+ list() assigns the values as if they were an array starting with the right-most parameter.
+ To return a reference from a function, use '&' in both the function declaration and when assigning the returned value to a variable
+ Heredoc text behaves as if it were enclosed in a double-quoted string, without the double quotes.
+ Member overloading only works in object context.
+ Quotes in a heredoc do not need to be escaped, but escape codes can still be used.
+ Overloading in PHP provides means to dynamically "create" members and methods.
+ All overloading methods must be defined as public.
+ To allow persistant sessions across browser closure, store an entry in the database indicating login time.
+ register_globals should always be disabled.
+ In PHP global variables must be declared global inside a function if they are going to be used in that function.
+ key() returns the index element of the current array position
+ $var == NULL will evaluate as TRUE if $var is zero or an empty string. To avoid this, remember to use : $var === NULL
+ "FALSE" is considered boolean TRUE
+ printf('%b', 4); outputs 100
+ When dealing with PHP sessions, what function is needed on every page? session_start()
+ It is discouraged to rely on the register_globals directive. Use other means, such as the superglobals.
+ A static variable exists only in a local function scope, but it does not lose its value when program execution leaves this scope.
+ function test(){ static $a = 0; echo $a; $a++;}test();test();test(); outputs 012
+ To retrieve the full path and filename of the file use the __FILE__ predefined constant.
+ If __FILE__ is used inside an include, the name of the included file is returned.
+ register_globals is not available in PHP 6.
+ $var = 10; function fn() { print($GLOBALS['var']); } fn(); outputs 10
+ assignment operators have relatively low precedence
+ $var = 5 + "-1.5e3"; ... $var is now equal to -1495
+ "0" is considered boolean FALSE
+ An empty array is considered boolean FALSE
+ echo 2 ^ "3"; outputs 1
+ || is called the logical OR operator
+ English-word boolean operators have low precedence--in fact they take place after assignment
+ echo 5 | 3; outputs 7
+ echo 5 >> 2; outputs 1
+ | is called the bitwise OR operator
+ $x = 0xFFC ; $y = 4 ; $z = $x & $y; echo $z; outputs 4
+ :: is allowed to access methods that can perform static operations i.e. those that don't require object instantiation.
+ SOA is technology agnostic ... Supports open source & commercial platforms
+ To destroy all of the data associated with the current session, use session_destroy() function after calling session_unset()
+ Since fatal errors are semantic errors, the script does execute up until the error.
+ echo 0xFFC & 2; outputs 0. echo 0xFFC & 4; outputs 4
+ echo 2 << 4; outputs 32
+ for ($i = 2; $i <= 4; print $i, $i++); outputs 234
+ session_unset() is used to remove all variables in a session.
+ Two ways to write the PHP logical 'And' operator are and and &&
+ The reason for the two different variations of "and" and "or" operators is that they operate at different precedences.
+ session_id() is used to get or set the session id for the current session.


A Lefkon Development